Advertisement
Guest User

Untitled

a guest
Jul 20th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. import RPi.GPIO
  2.  
  3. # you must make relay PCB to control signal lamp
  4. # DO NOT CONNECT SIGNAL LAMP TO GPIO DIRECTLY
  5.  
  6. GPIO.setup(17, GPIO.OUT) # red
  7. GPIO.setup(27, GPIO.OUT) # yellow
  8. GPIO.setup(22, GPIO.OUT) # green
  9.  
  10. def signal_lamp(lamp):
  11. if lamp == "red":
  12. GPIO.output(17, 1)
  13. GPIO.output(27, 0)
  14. GPIO.output(22, 0)
  15. elif lamp == "yellow":
  16. GPIO.output(17, 0)
  17. GPIO.output(27, 1)
  18. GPIO.output(22, 0)
  19. elif lamp == "green":
  20. GPIO.output(17, 0)
  21. GPIO.output(27, 0)
  22. GPIO.output(22, 1)
  23. elif lamp == "test":
  24. GPIO.output(17, 1)
  25. GPIO.output(27, 1)
  26. GPIO.output(22, 1)
  27. elif lamp == "none":
  28. GPIO.output(17, 0)
  29. GPIO.output(27, 0)
  30. GPIO.output(22, 0)
  31. else:
  32. return 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement