Advertisement
Guest User

Untitled

a guest
Feb 24th, 2020
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. import time
  2. import RPi.GPIO as GPIO
  3.  
  4. # Pin definitions
  5. led_pin_r = 4
  6. led_pin_g = 5
  7. led_pin_b = 6
  8.  
  9. # Use "GPIO" pin numbering
  10. GPIO.setmode(GPIO.BCM)
  11.  
  12. # Set LED pin as output
  13. GPIO.setup(led_pin_r, GPIO.OUT)
  14. GPIO.setup(led_pin_g, GPIO.OUT)
  15. GPIO.setup(led_pin_b, GPIO.OUT)
  16.  
  17. # Blink forever
  18. try:
  19. while True:
  20. GPIO.output(led_pin_r, GPIO.HIGH) # Turn LED on
  21. time.sleep(1) # Delay for 1 second
  22. GPIO.output(led_pin_r, GPIO.LOW) # Turn LED off
  23. time.sleep(1) # Delay for 1 second
  24.  
  25. # When you press ctrl+c, nicely release GPIO resources
  26. finally:
  27. GPIO.cleanup()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement