Guest User

Untitled

a guest
Jan 20th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. import RPi.GPIO as GPIO
  2. import time
  3.  
  4. channel = 21
  5.  
  6. # GPIO setup
  7. GPIO.setmode(GPIO.BCM)
  8. GPIO.setup(channel, GPIO.OUT)
  9.  
  10.  
  11. def light_on(pin):
  12. GPIO.output(pin, GPIO.HIGH) # Turn light on
  13.  
  14. def light_off(pin):
  15. GPIO.output(pin, GPIO.LOW) # Turn light off
  16.  
  17. if __name__ == '__main__':
  18. try:
  19. light_off(channel)
  20. time.sleep(1)
  21. light_on(channel)
  22. time.sleep(1)
  23. GPIO.cleanup()
  24. except KeyboardInterrupt:
  25. GPIO.cleanup()
Add Comment
Please, Sign In to add comment