Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2017
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. #!/usr/bin/env python
  2. import RPi.GPIO as GPIO
  3. import time
  4. LedPin = 11 # pin11
  5. def setup():
  6. GPIO.setmode(GPIO.BOARD) # Numbers GPIOs by physical location
  7. GPIO.setup(LedPin, GPIO.OUT) # Set LedPin's mode is output
  8. GPIO.output(LedPin, GPIO.HIGH) # Set LedPin high(+3.3V) to off led
  9. def loop():
  10. while True:
  11. print '...led on'
  12. GPIO.output(LedPin, GPIO.LOW) # led on
  13. time.sleep(0.5)
  14. print 'led off...'
  15. GPIO.output(LedPin, GPIO.HIGH) # led off
  16. time.sleep(0.5)
  17. def destroy():
  18. GPIO.output(LedPin, GPIO.HIGH) # led off
  19. GPIO.cleanup() # Release resource
  20. if __name__ == '__main__': # Program start from here
  21. setup()
  22. try:
  23. loop()
  24. except KeyboardInterrupt: # When 'Ctrl+C' is pressed, the child program destroy() will be executed.
  25. destroy()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement