|
3 | 3 | import board
|
4 | 4 | import adafruit_dotstar as dotstar
|
5 | 5 |
|
6 |
| -# One pixel connected internally on a GEMMA M0 |
7 |
| -# pylint: disable=no-member |
| 6 | +# On-board DotStar for boards including Gemma, Trinket, and ItsyBitsy |
8 | 7 | dots = dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1, brightness=0.2)
|
9 | 8 |
|
10 |
| -# With a Dotstar Digital LEB Strip with 30 lights |
11 |
| -#dots = dotstar.DotStar(board.SCK, board.MOSI, 30, brightness=0.2) |
| 9 | +# Using a DotStar Digital LED Strip with 30 LEDs connected to hardware SPI |
| 10 | +# dots = dotstar.DotStar(board.SCK, board.MOSI, 30, brightness=0.2) |
12 | 11 |
|
13 |
| -######################### HELPERS ############################## |
| 12 | +# Using a DotStar Digital LED Strip with 30 LEDs connected to digital pins |
| 13 | +# dots = dotstar.DotStar(board.D6, board.D5, 30, brightness=0.2) |
14 | 14 |
|
| 15 | + |
| 16 | +# HELPERS |
15 | 17 | # a random color 0 -> 224
|
16 | 18 | def random_color():
|
17 | 19 | return random.randrange(0, 7) * 32
|
18 | 20 |
|
19 |
| -######################### MAIN LOOP ############################## |
| 21 | + |
| 22 | +# MAIN LOOP |
20 | 23 | n_dots = len(dots)
|
21 | 24 | while True:
|
22 |
| - #fill each dot with a random color |
| 25 | + # Fill each dot with a random color |
23 | 26 | for dot in range(n_dots):
|
24 | 27 | dots[dot] = (random_color(), random_color(), random_color())
|
25 | 28 |
|
26 |
| - # show all dots in strip |
27 |
| - dots.show() |
28 |
| - |
29 | 29 | time.sleep(.25)
|
0 commit comments