Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- import RPi.GPIO as GPIO
- import time
- import random
- GPIO_RED = 10
- GPIO_GREEN = 9
- GPIO_BLUE = 11
- GPIOS = (GPIO_RED, GPIO_GREEN, GPIO_BLUE)
- GPIO.setmode(GPIO.BCM)
- for gpio in GPIOS:
- GPIO.setup(gpio, GPIO.OUT)
- def rand():
- return random.choice((False, True))
- def setcolor(r, g, b):
- GPIO.output(GPIO_RED, r)
- GPIO.output(GPIO_GREEN, g)
- GPIO.output(GPIO_BLUE, b)
- if __name__ == '__main__':
- try:
- while True:
- setcolor(rand(), rand(), rand())
- time.sleep(random.random())
- except KeyboardInterrupt:
- GPIO.cleanup()
Add Comment
Please, Sign In to add comment