It's easy to use the Pixel Trinkey with CircuitPython and the Adafruit_CircuitPython_DotStar module. This module allows you to easily write Python code that lets you control DotStar LEDs.

Connect your DotStars to the terminal block on the Pixel Trinkey:
- Board GND to DotStar GND (black wire)
- Board DATA to DotStar DATA (blue wire)
- Board CLOCK to DotStar CLOCK (green wire)
- Board +5V to DotStar VIN (red wire)
CircuitPython Usage
To use with CircuitPython, you need to first install the DotStar library, and its dependencies, into the lib folder on your CIRCUITPY drive. Then you need to update code.py with the example script.
Thankfully, we can do this in one go. In the example below, click the Download Project Bundle button below to download the necessary libraries and the code.py file in a zip file. Extract the contents of the zip file, and copy the entire lib folder and the code.py file to your CIRCUITPY drive.
Your CIRCUITPY/lib folder should contain the following files:
- adafruit_pixelbuf.mpy
- adafruit_dotstar.mpy

# SPDX-FileCopyrightText: 2024 Liz Clark for Adafruit Industries # SPDX-License-Identifier: MIT import time import board from rainbowio import colorwheel import adafruit_dotstar as dotstar clock_pin = board.CLOCK data_pin = board.DATA num_dots = 30 speed = 0.01 brightness = 0.2 order = "PGBR" # PGBR, PGRB, PRBG or PRGB dots = dotstar.DotStar(clock_pin, data_pin, num_dots, brightness=brightness, auto_write=True, pixel_order=order) hue = 0 dots.fill(colorwheel(hue)) while True: hue = (hue + 1) % 256 dots.fill(colorwheel(hue)) time.sleep(speed)
Once everything is saved to the CIRCUITPY drive, you'll see your connected DotStar strip cycle through a rainbow animation on a loop.
You can edit the variables in the code for the number of LEDs, speed, brightness and color order depending on your needs.
clock_pin = board.CLOCK data_pin = board.DATA num_dots = 30 speed = 0.01 brightness = 0.2 order = "PGBR" # PGBR, PGRB, PRBG or PRGB
Page last edited January 21, 2025
Text editor powered by tinymce.