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: two or three LEDs are on at the same time. # Note that each pair is on for 0.4 seconds for i in range(7): # repeat the pattern 7 times tree.leds_on_and_wait(L1 + L4, 0.4) # LED 1 and LED 4 tree.leds_on_and_wait(L5 + L3 + L0, 0.4) # LEDs 5, 3 and 0 tree.leds_on_and_wait(L2 + L6, 0.4) # LEDs 2 and 6 tree.leds_on_and_wait(L5 + L3 + L0, 0.4) # LEDs 5, 3 and 0 tree.all_leds_off() # extinguish all LEDs # All done! tree.cleanup() # call cleanup() at the end
import tree # Some constants to identify each LED L0 = 1 L1 = 2 L2 = 4 L3 = 8 L4 = 16 L5 = 32 L6 = 64 BOTTOM_ROW = 14 MIDDLE_ROW = 48 ALL = 1+2+4+8+16+32+64 NO_LEDS = 0 tree.setup() # you must always call setup() first! for i in range(5): tree.leds_on_and_wait(BOTTOM_ROW+L0, 0.5) tree.leds_on_and_wait(MIDDLE_ROW+BOTTOM_ROW+L0, 0.5) tree.leds_on_and_wait(L6+MIDDLE_ROW+BOTTOM_ROW+L0, 0.5) tree.leds_on_and_wait(L0, 0.5) tree.all_leds_off() tree.cleanup()
L4 = 16 L5 = 32 L6 = 64 AMBER = 1 # LED 0 = amber RED = 128 # LED 0 = red GREEN = 256 # LED 0 = green NO_LEDS = 0 BOTTOM6 = 2+4+8+16+32+64 # the 6 standard red LEDs # note that we must tell setup() that we have a bicolour LED tree.setup() # you must always call setup() first! # All the red LEDs will be permanently illuminated and we rotate # between the various colours for the bicolour LED at the top. for i in range(7): # repeat 7 times tree.leds_on_and_wait(BOTTOM6, 0.8) # top LED off tree.leds_on_and_wait(BOTTOM6 + GREEN, 0.8) # top LED green tree.leds_on_and_wait(BOTTOM6 + RED, 0.8) # top LED red tree.leds_on_and_wait(BOTTOM6 + AMBER, 0.8) # top LED amber tree.leds_on_and_wait(NO_LEDS, 0.8) # all LEDs off tree.leds_on_and_wait(GREEN, 0.8) # top LED green tree.leds_on_and_wait(RED, 0.8) # top LED red tree.leds_on_and_wait(AMBER, 0.8) # top LED amber tree.all_leds_off() # extinguish all LEDs # All done! tree.cleanup() # call cleanup() at the end
elif random_led == 2: for y in range(4): pattern2() elif random_led == 3: for y in range(10): pattern3() elif random_led == 4: for y in range(4): pattern4() elif random_led == 5: pattern5() elif random_led == 6: for y in range(2): pattern6() elif random_led == 7: for y in range(5): pattern7() elif random_led == 8: for y in range(20): pattern8() elif random_led == 9: for y in range(20): pattern9() except KeyboardInterrupt: tree.all_leds_off() tree.cleanup() sys.exit() tree.all_leds_off() tree.cleanup()