Cannot get a Pin to work with a microswitch
Posted: Thu Mar 05, 2015 7:07 am
Hi everyone,
I'm doing some experiments with my brand new Pyboard 1.0 (coolest thing in many years). I started playing with the built-in switches and now I've connected a tactile microswitch to Y11 and V3.3 on each side of the jumper. I'm using the following code, which I believe is correct. However the blue led turns on right after booting and stays this way no matter what I do with the switch.
It's my undertanding that if I do:
It should be reading 0?
And that if I set any other pin, without nothing connected to it to a pull down, it should be reading 0 unless I draw power to it. Just in case i upgraded firmware this morning to Micro Python v1.3.10-147-g16b1f5e on 2015-03-05; PYBv1.0 with STM32F405RG.
Thanks, cheers
Miguel
I'm doing some experiments with my brand new Pyboard 1.0 (coolest thing in many years). I started playing with the built-in switches and now I've connected a tactile microswitch to Y11 and V3.3 on each side of the jumper. I'm using the following code, which I believe is correct. However the blue led turns on right after booting and stays this way no matter what I do with the switch.
Code: Select all
import time,pyb
switch = pyb.Pin("Y11", pyb.Pin.IN)
switch.init(pyb.Pin.IN, pull=pyb.Pin.PULL_DOWN)
blue_led = pyb.LED(4)
while True:
if switch.value():
blue_led.on()
else:
blue_led.off()
time.sleep(0.05)
Code: Select all
>>> pyb.Pin.board.Y1.low()
>>> pyb.Pin.board.Y1.value()
1
And that if I set any other pin, without nothing connected to it to a pull down, it should be reading 0 unless I draw power to it. Just in case i upgraded firmware this morning to Micro Python v1.3.10-147-g16b1f5e on 2015-03-05; PYBv1.0 with STM32F405RG.
Thanks, cheers
Miguel