Advertisement
ElfikCo

Untitled

Dec 9th, 2019
381
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. import RPi.GPIO as GPIO
  2. import time
  3.  
  4. GPIO.setwarnings(False)
  5. GPIO.setmode(GPIO.BCM)
  6.  
  7. PIN_LED_RED = 14
  8. PIN_LED_GRE = 23
  9. PIN_BUTTON = 15
  10.  
  11. GPIO.setup(PIN_LED_RED, GPIO.OUT)
  12. GPIO.setup(PIN_LED_GRE, GPIO.OUT)
  13. GPIO.setup(PIN_BUTTON, GPIO.IN)
  14. GPIO.output(PIN_LED_RED, 1)
  15. btn_clicked = False
  16. i = 5
  17. while True:
  18. btn_clicked = GPIO.input(PIN_BUTTON)
  19. if i <= 0:
  20. if btn_clicked == True:
  21. GPIO.output(PIN_LED_RED, 0)
  22. GPIO.output(PIN_LED_GRE, 1)
  23. time.sleep(5)
  24. GPIO.output(PIN_LED_GRE, GPIO.HIGH)
  25. time.sleep(0.1)
  26. GPIO.output(PIN_LED_GRE, GPIO.LOW)
  27. time.sleep(0.1)
  28. GPIO.output(PIN_LED_GRE, GPIO.HIGH)
  29. time.sleep(0.1)
  30. GPIO.output(PIN_LED_GRE, GPIO.LOW)
  31. time.sleep(0.1)
  32. GPIO.output(PIN_LED_GRE, GPIO.HIGH)
  33. time.sleep(0.1)
  34. GPIO.output(PIN_LED_GRE, GPIO.LOW)
  35. GPIO.output(PIN_LED_RED, 1)
  36. i = 5
  37. i = i - 1
  38.  
  39.  
  40. GPIO.cleanup();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement