Simple test¶
Ensure your device works with this simple test.
examples/dotstar_simpletest.py¶
1# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
2# SPDX-License-Identifier: MIT
3
4import time
5import random
6import board
7import adafruit_dotstar as dotstar
8
9# On-board DotStar for boards including Gemma, Trinket, and ItsyBitsy
10dots = dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1, brightness=0.2)
11
12# Using a DotStar Digital LED Strip with 30 LEDs connected to hardware SPI
13# dots = dotstar.DotStar(board.SCK, board.MOSI, 30, brightness=0.2)
14
15# Using a DotStar Digital LED Strip with 30 LEDs connected to digital pins
16# dots = dotstar.DotStar(board.D6, board.D5, 30, brightness=0.2)
17
18
19# HELPERS
20# a random color 0 -> 192
21def random_color():
22 return random.randrange(0, 7) * 32
23
24
25# MAIN LOOP
26n_dots = len(dots)
27while True:
28 # Fill each dot with a random color
29 for dot in range(n_dots):
30 dots[dot] = (random_color(), random_color(), random_color())
31
32 time.sleep(0.25)