-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpush.py
15 lines (13 loc) · 1022 Bytes
/
push.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import RPi.GPIO as GPIO # Import Raspberry Pi GPIO library
def button_callback(channel):
print(f"Button was pushed!{channel}")
GPIO.setwarnings(False) # Ignore warning for now
GPIO.setmode(GPIO.BOARD) # Use physical pin numbering
GPIO.setup(11, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) # Set pin 10 to be an input pin and set initial value to be pulled low (off)
GPIO.add_event_detect(11, GPIO.RISING,callback=button_callback) # Setup event on pin 10 rising edge
GPIO.setup(10, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) # Set pin 10 to be an input pin and set initial value to be pulled low (off)
GPIO.add_event_detect(10, GPIO.RISING,callback=button_callback) # Setup event on pin 10 rising edge
GPIO.setup(7, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) # Set pin 10 to be an input pin and set initial value to be pulled low (off)
GPIO.add_event_detect(7,GPIO.RISING,callback=button_callback) # Setup event on pin 10 rising edge
message = input("Press enter to quit\n\n") # Run until someone presses enter
GPIO.cleanup() # Clean up