Advertisement
Guest User

Untitled

a guest
Dec 5th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. import RPi.GPIO as GPIO
  4. import time
  5. import os
  6.  
  7. buttonShutdown = 6
  8. button9x9 = 13
  9. buttonNext = 19
  10. buttonPrev = 26
  11.  
  12. GPIO.setmode(GPIO.BCM)
  13. GPIO.setup(buttonShutdown, GPIO.IN)
  14. GPIO.setup(button9x9, GPIO.IN)
  15. GPIO.setup(buttonNext, GPIO.IN)
  16. GPIO.setup(buttonPrev, GPIO.IN)
  17.  
  18. GPIO.add_event_detect(buttonShutdown, GPIO.FALLING)
  19. GPIO.add_event_detect(button9x9, GPIO.FALLING)
  20. GPIO.add_event_detect(buttonNext, GPIO.FALLING)
  21. GPIO.add_event_detect(buttonPrev, GPIO.FALLING)
  22.  
  23. while True:
  24. if GPIO.event_detected(buttonShutdown):
  25. cmd = "echo shutdown"
  26. os.system(cmd)
  27. if GPIO.event_detected(button9x9):
  28. cmd = "echo 9x9"
  29. os.system(cmd)
  30. if GPIO.event_detected(buttonNext):
  31. cmd = "echo next"
  32. os.system(cmd)
  33. if GPIO.event_detected(buttonPrev):
  34. cmd = "echo prev"
  35. os.system(cmd)
  36. time.sleep(0.1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement