User Manual

That's all there is to getting started with CircuitPython and DotStar LEDs!
Below is an example that turns all 30 LEDs random colors. To use, download the file, rename it to code.py and copy it
to your board!
Full Example Code
import time
import random
import board
import adafruit_dotstar as dotstar
# On-board DotStar for boards including Gemma, Trinket, and ItsyBitsy
dots = dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1, brightness=0.2)
# Using a DotStar Digital LED Strip with 30 LEDs connected to hardware SPI
# dots = dotstar.DotStar(board.SCK, board.MOSI, 30, brightness=0.2)
# Using a DotStar Digital LED Strip with 30 LEDs connected to digital pins
# dots = dotstar.DotStar(board.D6, board.D5, 30, brightness=0.2)
# HELPERS
# a random color 0 -> 224
def random_color():
return random.randrange(0, 7) * 32
# MAIN LOOP
n_dots = len(dots)
while True:
# Fill each dot with a random color
for dot in range(n_dots):
dots[dot] = (random_color(), random_color(), random_color())
time.sleep(.25)
© Adafruit Industries https://learn.adafruit.com/adafruit-dotstar-leds Page 47 of 48