Advertisement
zvika

Raspberry Pi Button Event Example

Oct 22nd, 2018
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.36 KB | None | 0 0
  1. import RPi.GPIO as GPIO
  2.  
  3. def button_callback(channel):
  4.     print("Button was pushed!")
  5.  
  6. gpioPin = 13
  7.  
  8. # GPIO.setwarnings(False)
  9. GPIO.setmode(GPIO.BCM)
  10. GPIO.setup(gpioPin, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
  11.  
  12. GPIO.add_event_detect(gpioPin,GPIO.RISING,callback=button_callback)
  13. message = input_raw("Press enter to quit\n\n")
  14.  
  15. GPIO.cleanup() # Clean up
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement