Skip to content

Commit 492dc83

Browse files
authored
Merge pull request #11 from mrmcwethy/examples
added examples folder and .py file
2 parents 3d3a039 + e64dd6f commit 492dc83

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

examples/randomcolor.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import time
2+
import random
3+
import board
4+
import adafruit_dotstar as dotstar
5+
6+
# One pixel connected internally on a GEMMA M0
7+
dots = dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1, brightness=0.2)
8+
9+
# With a Dotstar Digital LEB Strip with 30 lights
10+
#dots = dotstar.DotStar(board.SCK, board.MOSI, 30, brightness=0.2)
11+
12+
######################### HELPERS ##############################
13+
14+
# a random color 0 -> 224
15+
def random_color():
16+
return random.randrange(0, 7) * 32
17+
18+
######################### MAIN LOOP ##############################
19+
n_dots = len(dots)
20+
while True:
21+
#fill each dot with a random color
22+
for dot in range(n_dots):
23+
dots[dot] = (random_color(), random_color(), random_color())
24+
25+
# show all dots in strip
26+
dots.show()
27+
28+
time.sleep(.25)

0 commit comments

Comments
 (0)