Initial commit of Xmas tree
[pi-xmas.git] / xmas_tree / example_bicolour.py
1 import tree
2
3 # some constants to identify each LED
4 L1 = 2
5 L2 = 4
6 L3 = 8
7 L4 = 16
8 L5 = 32
9 L6 = 64
10 AMBER = 1 # LED 0 = amber
11 RED = 128 # LED 0 = red
12 GREEN = 256 # LED 0 = green
13 NO_LEDS = 0
14 BOTTOM6 = 2+4+8+16+32+64 # the 6 standard red LEDs
15
16 # note that we must tell setup() that we have a bicolour LED
17 tree.setup() # you must always call setup() first!
18
19 # All the red LEDs will be permanently illuminated and we rotate
20 # between the various colours for the bicolour LED at the top.
21 for i in range(7): # repeat 7 times
22 tree.leds_on_and_wait(BOTTOM6, 0.8) # top LED off
23 tree.leds_on_and_wait(BOTTOM6 + GREEN, 0.8) # top LED green
24 tree.leds_on_and_wait(BOTTOM6 + RED, 0.8) # top LED red
25 tree.leds_on_and_wait(BOTTOM6 + AMBER, 0.8) # top LED amber
26
27 tree.leds_on_and_wait(NO_LEDS, 0.8) # all LEDs off
28 tree.leds_on_and_wait(GREEN, 0.8) # top LED green
29 tree.leds_on_and_wait(RED, 0.8) # top LED red
30 tree.leds_on_and_wait(AMBER, 0.8) # top LED amber
31
32 tree.all_leds_off() # extinguish all LEDs
33
34 # All done!
35 tree.cleanup() # call cleanup() at the end
36