Skip to content

Commit 0a4d3ba

Browse files
author
Kevin J Walters
committed
New examples/ws2801_simpletest.py based on the DotStar example, tested on GEMMA M0.
1 parent 6c1d76e commit 0a4d3ba

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

examples/ws2801_simpletest.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
### Based on https://github.com/adafruit/Adafruit_CircuitPython_DotStar/blob/master/examples/dotstar_simpletest.py
2+
3+
import time
4+
import random
5+
import board
6+
import adafruit_ws2801
7+
8+
### Example for a GEMMA M0 driving 50 12mm leds
9+
oclock=board.D2
10+
odata=board.D0
11+
numleds=50
12+
bright=1.0
13+
leds = adafruit_ws2801.WS2801(oclock, odata, numleds, brightness=bright, auto_write=False)
14+
15+
######################### HELPERS ##############################
16+
17+
# a random color 0 -> 224
18+
def random_color():
19+
return random.randrange(0, 7) * 32
20+
21+
######################### MAIN LOOP ##############################
22+
n_leds = len(leds)
23+
while True:
24+
#fill each led with a random color
25+
for idx in range(n_leds):
26+
leds[idx] = (random_color(), random_color(), random_color())
27+
28+
# show all leds in led string
29+
leds.show()
30+
31+
time.sleep(.25)

0 commit comments

Comments
 (0)