Advertisement
Guest User

raspberry-python-input

a guest
Jan 27th, 2015
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.53 KB | None | 0 0
  1. import RPi.GPIO as GPIO
  2. GPIO.setmode(GPIO.BCM)
  3. GPIO.setup(2, GPIO.IN, pull_up_down = GPIO.PUD_DOWN)
  4. GPIO.setup(3, GPIO.IN, pull_up_down = GPIO.PUD_UP)
  5. def printFunction(channel):
  6.     print("Button 1 pressed!")
  7.     print("Note how the bouncetime affects the button press")
  8.    
  9. GPIO.add_event_detect(2, GPIO.FALLING, callback=printFunction, bouncetime=300)
  10.  
  11. while True:
  12.     GPIO.wait_for_edge(3, GPIO.FALLING)
  13.     print("Button 2 Pressed")
  14.     GPIO.wait_for_edge(3, GPIO.RISING)
  15.     print("Button 2 Released")
  16. GPIO.cleanup()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement