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 random
 5import time
 6
 7import board
 8
 9import adafruit_dotstar as dotstar
10
11# On-board DotStar for boards including Gemma, Trinket, and ItsyBitsy
12dots = dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1, brightness=0.2)
13
14# Using a DotStar Digital LED Strip with 30 LEDs connected to hardware SPI
15# dots = dotstar.DotStar(board.SCK, board.MOSI, 30, brightness=0.2)
16
17# Using a DotStar Digital LED Strip with 30 LEDs connected to digital pins
18# dots = dotstar.DotStar(board.D6, board.D5, 30, brightness=0.2)
19
20
21# HELPERS
22# a random color 0 -> 192
23def random_color():
24    return random.randrange(0, 7) * 32
25
26
27# MAIN LOOP
28n_dots = len(dots)
29while True:
30    # Fill each dot with a random color
31    for dot in range(n_dots):
32        dots[dot] = (random_color(), random_color(), random_color())
33
34    time.sleep(0.25)