Difference between revisions of "Push button"
Jump to navigation
Jump to search
Line 7: | Line 7: | ||
This is the most simple way of connecting a button. if the button is not pressed (open) there is no signal at the pin. Hence here we should use an internal pullup resistor. | This is the most simple way of connecting a button. if the button is not pressed (open) there is no signal at the pin. Hence here we should use an internal pullup resistor. | ||
− | [[File:Button01.PNG] | + | [[File:Button01.PNG]] |
This is the connection of a button with a pullup resistor. If the button is not pressed, 3.3V are connected to the pin via the 10 KOhm resistor (reads 1). if it is pressed it is connected to GND (reads 0). | This is the connection of a button with a pullup resistor. If the button is not pressed, 3.3V are connected to the pin via the 10 KOhm resistor (reads 1). if it is pressed it is connected to GND (reads 0). | ||
− | [[File:Pullup02.PNG] | + | [[File:Pullup02.PNG]] |
= How to control it in MicroPython = | = How to control it in MicroPython = |
Revision as of 23:10, 29 August 2020
Contents
Description
With a button we can select which of the two sides are connected to the middle. It is similar to a switch but it only stays in the state as long as it is pressed.
How to connect it electrically
This is the most simple way of connecting a button. if the button is not pressed (open) there is no signal at the pin. Hence here we should use an internal pullup resistor.
This is the connection of a button with a pullup resistor. If the button is not pressed, 3.3V are connected to the pin via the 10 KOhm resistor (reads 1). if it is pressed it is connected to GND (reads 0).
How to control it in MicroPython
1 from machine import Pin
2 in26 = Pin(26, Pin.IN)
3 print(in26.value())
Related Tutorial Videos
Digital Input