forked from mellowdrifter/Christmas_Lights
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lights.py
56 lines (47 loc) · 1.54 KB
/
lights.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
49
50
51
52
53
54
55
56
#!/usr/bin/python
import tree
# Some constants to identify each LED
L0 = 1
L1 = 2
L2 = 4
L3 = 8
L4 = 16
L5 = 32
L6 = 64
ALL = 1+2+4+8+16+32+64
NO_LEDS = 0
tree.setup() # you must always call setup() first!
# Pattern: flash each LED in turn
x = 1
while x == 1:
try:
for i in range (2):
tree.leds_on_and_wait(L0, 0.3) # LED 0 on for 0.3 seconds
tree.leds_on_and_wait(L1, 0.3) # LED 1 on for 0.3 seconds
tree.leds_on_and_wait(L2, 0.3) # etc.
tree.leds_on_and_wait(L3, 0.3)
tree.leds_on_and_wait(L4, 0.3)
tree.leds_on_and_wait(L5, 0.3)
tree.leds_on_and_wait(L6, 0.3)
for i in range (2):
tree.leds_on_and_wait(L4+L5, 1)
tree.leds_on_and_wait(L0+L2, 1)
tree.leds_on_and_wait(L3+L6+L1, 1)
for i in range (3):
tree.leds_on_and_wait(ALL, 0.8)
tree.leds_on_and_wait(NO_LEDS, 0.8)
for i in range (6):
tree.leds_on_and_wait(L6, 0.1)
tree.leds_on_and_wait(L5, 0.1)
tree.leds_on_and_wait(L4, 0.1)
tree.leds_on_and_wait(L3, 0.1)
tree.leds_on_and_wait(L2, 0.1)
tree.leds_on_and_wait(L1, 0.1)
tree.leds_on_and_wait(L0, 0.1)
for i in range (3):
tree.leds_on_and_wait(ALL, 0.8)
tree.leds_on_and_wait(NO_LEDS, 0.8)
except (KeyboardInterrupt, SystemExit):
tree.all_leds_off() # extinguish all LEDs
# All done!
tree.cleanup() # call cleanup() at the end