Guest User

Untitled

a guest
Jan 17th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. def PlaySequence():
  2. GPIO.output(LED1, True)
  3. time.sleep(5)
  4. GPIO.output(LED2, True)
  5. time.sleep(1)
  6. GPIO.output(LED1, False)
  7. time.sleep(3)
  8. GPIO.output(LED1, True)
  9. GPIO.output(LED2, True)
  10. time.sleep(7)
  11. GPIO.output(LED2, False)
  12. time.sleep(12)
  13. GPIO.output(LED1, True)
  14. time.sleep(2)
  15. ...
  16.  
  17. GPIO.add_event_detect(button, GPIO.RISING, callback=PlaySequence)
  18.  
  19. event press detected
  20. loop
  21. if gpio pin is low
  22. turn off all leds
  23. break loop
  24.  
  25. def PlaySequence(button):
  26. GPIO.output(LED1, True)
  27. if not GPIO.input(button):
  28. return
  29. time.sleep(5)
  30. GPIO.output(LED2, True)
  31. if not GPIO.input(button):
  32. return
  33. time.sleep(1)
  34. GPIO.output(LED1, False)
  35. if not GPIO.input(button):
  36. return
  37. time.sleep(3)
  38. GPIO.output(LED1, True)
  39. GPIO.output(LED2, True)
  40. if not GPIO.input(button):
  41. return
  42. time.sleep(7)
  43. GPIO.output(LED2, False)
  44. if not GPIO.input(button):
  45. return
  46. time.sleep(12)
  47. GPIO.output(LED1, True)
  48. if not GPIO.input(button):
  49. return
  50. time.sleep(2)
Add Comment
Please, Sign In to add comment