www.joy-it.net
Pascalstr. 8 47506 Neukirchen-Vluyn
2 BUTTON MODULE
SBC-Button2
1. GENERAL INFORMATION
Dear customer,
thank you very much for choosing our product.
In following, we will introduce you to what to observe while starting up
and using this product.
Should you encounter any unexpected problems during use, please do
not hesitate to contact us.
Connected as standard, the module is operated in high-active mode.
This means that a high signal is applied to the signal pin when the button
is pressed.
Due to the resistors integrated on the board, the signal is pulled to 0 V if
no button is pressed.
However, the module can also be operated low-active.
To do this, you only have to swap the VCC and GND connections.
This way a high signal is present when the button is not pressed and a
low signal when the button is pressed.
www.joy-it.net
Pascalstr. 8 47506 Neukirchen-Vluyn
2. APPLICATION WITH THE RASPBERRY PI
Wiring:
The following example program displays the status of the two buttons
every 2 seconds.
Raspberry Pi Button
Pin 11 (BCM 17) S1
Pin 13 (BCM 27) S2
5 V VCC
GND GND
from time import sleep
import RPi.GPIO as GPIO
#Initialisation
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
button1 = 17
button2 = 27
GPIO.setup(button1, GPIO.IN)
GPIO.setup(button2, GPIO.IN)
# Button Query
while True:
if GPIO.input(button1) == GPIO.HIGH:
print ("Button 1 pressed!")
else:
print ("Button 1 not pressed!")
if GPIO.input(button2) == GPIO.HIGH:
print ("Button 2 pressed!")
else:
print ("Button 2 not pressed!")
print ("-----------------------------------")
sleep(2)