Parts

APA102 (DotStar) LED strip

Addressable RGB LEDs with a clock wire and a data wire, so any speed works. Aliases: DotStar, SK9822, APA102C, Adafruit DotStar strip.

Each LED reads its data line on the rising edge of the clock, so the board sets the pace: a slow digitalWrite() loop, hardware SPI or an interrupt in the middle of a frame all work. A WS2812 needs every bit timed to a fraction of a microsecond instead. count sets how many LEDs the strip has, 1 to 1024.

Pins

Pin What it does
VCC Supply, 5 V (the datasheet's typical; 5.5 V max). Printed 5V on a DotStar strip.
CI Clock in, from the board.
DI Data in, from the board.
GND Ground.
CO Clock out, to the next strip's CI.
DO Data out, to the next strip's DI.

The frames

From the APA102 datasheet, 32 bits at a time, most significant bit first:

Frame Bits
Start 32 zeros
One per LED 111, a 5-bit global brightness, then blue, green and red, 8 bits each
End Ones, at least one clock for every two LEDs

The global brightness sets the LED's current in 31 steps (11111 is full, 00000 is off) on top of each color's 0 to 255 duty. The strip shows each channel as color x brightness / 31. The first LED keeps the first frame after the start frame and passes the rest on, so the second LED gets the second frame, and so on.

Why the end frame: each LED passes the data on half a clock late, but the clock itself is not delayed. The last LED of 30 only has its whole frame 15 clocks after the board sent it. Mokxi counts this, so a sketch that sends no end frame sees the far end of the strip update one show() late, as a real strip does.

In a sketch

Adafruit_DotStar.h (data and clock pins, or the board's SPI pins when you leave them out) and FastLED's addLeds<APA102, DATA_PIN, CLOCK_PIN, BGR> both light it. The part takes the colors in the datasheet's blue, green, red order, so use DOTSTAR_BGR. Adafruit's examples say DOTSTAR_BRG because some strips are wired that way; on this part that order swaps red and green.

#include <Adafruit_DotStar.h>
#include <SPI.h>

Adafruit_DotStar strip(30, 4, 5, DOTSTAR_BGR);   // data pin 4, clock pin 5

void setup() {
  strip.begin();
  strip.setBrightness(96);
}

void loop() {
  strip.rainbow(millis() * 64);
  strip.show();
  delay(20);
}

The DotStar rainbow example runs this on an Uno and prints how long each show() takes.

Levels

The inputs read high above 0.7 of the supply and low below 0.3 of it. On a 5 V strip that is 3.5 V, so a 3.3 V board (an ESP32 or a Pico) does not clock it: put a 74AHCT125 level shifter on CI and DI, or run the strip from 3.3 V. Below 3 V the strip is off.

What it does not model

The LEDs show their average color, not the PWM flicker underneath. A frame whose first three bits are not 111 is ignored (the datasheet's self-detection mode). No maximum clock rate is enforced, because the datasheet gives none; real strips run at 1 to 10 MHz and long ones want slower. The strip draws no current from the supply, where a real one pulls up to about 60 mA an LED at full white.