Line: 1 to 1 | ||||||||
---|---|---|---|---|---|---|---|---|
Solutions to the Exercise 3: SwitchesExercise 1:This is very similar to switching a LED on or off. Again a single GPIO line is used. This time however the pin in programmed as input and we can add a pullup or pulldown resistor: | ||||||||
Changed: | ||||||||
< < | _PB_PIN = 17 pushButton = Pin(_PB_PIN,Pin.IN,Pin.PULL_UP) | |||||||
> > |
_PB_PIN = 22 pushButton = Pin(_PB_PIN,Pin.IN,Pin.PULL_UP) | |||||||
Once the pushButton pin is defined we can get its current state with: | ||||||||
Added: | ||||||||
> > | ||||||||
state = pushButton.value() https://afnog.iotworkshop.africa/pub/IoT_Course_English/SolutionsToTheExerciseOnSwitches/pbPoll.py.txt |