-
Notifications
You must be signed in to change notification settings - Fork 6
/
XmasTree_Colours.py
33 lines (28 loc) · 1002 Bytes
/
XmasTree_Colours.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
#!/usr/bin/env python3
# XmasTree_Colours.py
# Set ALL LEDs to same colour using list, set top LED white
from tree import RGBXmasTree
from colorzero import Color
from time import sleep
# generate random floating point values
from random import seed
from random import random
# seed random number generator
seed(1)
# Set to LED number for top of Xmas Tree. LEDs are numbered 0-24.
TOP_LED = 3
# Instance the RGBXmasTree
tree = RGBXmasTree(brightness=0.05)
colors = [Color('cyan'), Color('yellow'), Color('purple'), Color('red'), Color('green'),
Color('blue'), Color('magenta')] # add more if you like, see https://www.rapidtables.com/web/color/RGB_Color.html#color-table.
# main loop
try:
while True:
for color in colors:
tree.color = color
# colour top LED white (will flash due to loop)
tree[TOP_LED].color = (1, 1, 1)
val = random()/10 # trying to make it 'sparkle'
sleep(val)
except KeyboardInterrupt:
tree.close()