Last active
December 11, 2019 19:36
-
-
Save odolezal/317cc684da579a0075522528beed4528 to your computer and use it in GitHub Desktop.
Random LED blinking for Cytron Maker pHAT
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Random LED blinking for Cytron Maker pHAT | |
#https://github.com/odolezal | |
#=========================== | |
from gpiozero import LED, Button, Buzzer | |
import random | |
from time import sleep | |
from threading import Thread | |
LED1 = LED(17) | |
LED2 = LED(18) | |
LED3 = LED(27) | |
LED4 = LED(22) | |
LED5 = LED(25) | |
LED6 = LED(12) | |
LED7 = LED(13) | |
LED8 = LED(19) | |
def func1(): | |
while True: | |
LED1.on() | |
sleep(random.random()) | |
LED1.off() | |
sleep(random.random()) | |
def func2(): | |
while True: | |
LED2.on() | |
sleep(random.random()) | |
LED2.off() | |
sleep(random.random()) | |
def func3(): | |
while True: | |
LED3.on() | |
sleep(random.random()) | |
LED3.off() | |
sleep(random.random()) | |
def func4(): | |
while True: | |
LED4.on() | |
sleep(random.random()) | |
LED4.off() | |
sleep(random.random()) | |
def func5(): | |
while True: | |
LED5.on() | |
sleep(random.random()) | |
LED5.off() | |
sleep(random.random()) | |
def func6(): | |
while True: | |
LED6.on() | |
sleep(random.random()) | |
LED6.off() | |
sleep(random.random()) | |
def func7(): | |
while True: | |
LED7.on() | |
sleep(random.random()) | |
LED7.off() | |
sleep(random.random()) | |
def func8(): | |
while True: | |
LED8.on() | |
sleep(random.random()) | |
LED8.off() | |
sleep(random.random()) | |
if __name__ == '__main__': | |
Thread(target = func1).start() | |
Thread(target = func2).start() | |
Thread(target = func3).start() | |
Thread(target = func4).start() | |
Thread(target = func5).start() | |
Thread(target = func6).start() | |
Thread(target = func7).start() | |
Thread(target = func8).start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment