-
Notifications
You must be signed in to change notification settings - Fork 0
/
hallowleds.py
49 lines (42 loc) · 935 Bytes
/
hallowleds.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
from gpiozero import LED
from time import sleep
import random
G = LED(4)
H = LED(17)
O = LED(27)
S = LED(22)
T = LED(5)
I = LED(6)
D = LED(13)
C = LED(19)
L = LED(26)
U = LED(20)
E = LED(21)
all_leds = [G, H, O, S, T, I, D, C, L, U, E]
answer = [G, O, O, U, T, S, I, D, E, D, I, G]
def all_flash():
# all blink complete sequence
for i in range(5):
for led in all_leds:
led.on()
sleep(1 / ((i + 1) ** 2))
for led in all_leds:
led.off()
sleep(0.5 / ((i + 1) ** 2))
def all_shuffle():
shuffled_leds = all_leds.copy()
shuffled_leds.extend(all_leds)
shuffled_leds.extend(all_leds)
shuffled_leds.extend(all_leds)
random.shuffle(shuffled_leds)
for led in shuffled_leds:
led.toggle()
sleep(0.2)
while True:
for led in answer:
led.on()
sleep(0.2)
led.off()
sleep(0.1)
all_flash()
sleep(5)