Initial commit of Xmas tree
[pi-xmas.git] / xmas_tree / example_4.py
1 import tree
2 import time
3
4 # Some constants to identify each LED
5 L0 = 1
6 L1 = 2
7 L2 = 4
8 L3 = 8
9 L4 = 16
10 L5 = 32
11 L6 = 64
12 ALL = 1+2+4+8+16+32+64
13 NO_LEDS = 0
14
15 tree.setup() # you must always call setup() first!
16
17 # Two slightly different ways of flashing *all* LEDs on and off.
18
19 # Way 1
20 for i in range(3): # repeat 3 times
21 tree.leds_on_and_wait(ALL, 0.5) # all on for 0.5s
22 tree.leds_on_and_wait(NO_LEDS, 0.5) # all off for 0.5s
23
24 # Way 2
25 for i in range(3): # repeat 3 times
26 tree.leds_on_and_wait(ALL, 0.5) # all on for 0.5s
27 tree.all_leds_off() # extinguish all LEDs
28 time.sleep(0.5) # wait for 0.5s
29
30
31 tree.all_leds_off() # extinguish all LEDs
32
33 # All done!
34 tree.cleanup() # call cleanup() at the end
35