Skip to main content

Driving APA102 (Dotstar) LED strips with Pico

The Dotstar LEDs (APA102) are similar to the NeoPixels but with less timing requirements and other requirements.issues. You control them with two pins instead of one, and they seem to be a bit less widely used probably because they're more expensive than the regular Neopixel ones.

For a quick test we cobbled together a series of scripts that at least get some light effects out of a Dotstar strip, starting out from CircuitPython. You will need the adafruit_dotstar library that you can find here: https://circuitpython.org/libraries (make sure you download the right library version for your version of circuitpython).

More info on Dotstar strips and matrices here, by Adafruit. Page 39 and on concerns Circuitpython.

Setup

Make sure your Pico has Circuitpython installed. Once you've done that, copy adafruit_dotstar to the lib folder and this effects.py to your Pico. Connect the pins of the Dotstar strip to your Pico: power to power (preferrably external power, see also here), CI (usually yellow) to pin 18 and DI (usually green) to pin 19.

Run the effects.py and your strip should light up, cycling through a couple of lighting effects.

effects.py

At the import on the top of the file you can switch between the auto_write False and True versions by importing either version of the micropython_dotstar file on line 2. Check the difference between the two to see which works best for your use case.

effects.py has a couple of settings on linesthe 12-16.top of the program.

  • num_pixels is the number of LEDs on your strip that you want lit. The program starts at the LED closest to the connection wires and then counts up.
  • sleepy_time is the time each LED is lit for some of the effects. Short wait times lead to quick blinking or more fluent lighting effects.
  • auto_write is set to False. When set to True, the program will wait until all leds are set before updating the entire strip at once. When set to False, each LED is updated individually. Which mode you need will depend on your use case, we set it to False to allow for faster lighting effects with longer strips. For strips up to ~10 LEDs you will hardly notice the difference.

Lines 23-115 define functions for the lighting effects, which are called in the main loop at 136.

APA.gif