Difference: SolutionsToTheExerciseOnSwitches (2 vs. 3)

Revision 32021-01-27 - UliRaich

Line: 1 to 1
 
META TOPICPARENT name="Solutions"

Solutions to the Exercise 3: Switches

Exercise 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

 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback