Source: https://mokxi.com/libraries/adafruit-dotstar
Updated: 2026-11-11

Libraries / LEDs

Arduino library · LEDs

# Adafruit DotStar: APA102 strips on a data and a clock pin

DotStar is Adafruit’s name for APA102 and SK9822 LEDs. Unlike the one-wire WS2812, each DotStar takes a separate clock line, so the timing is set by the board rather than by a tight 800 kHz signal. That makes DotStars happy on any pin, at any clock speed, and alongside interrupts and WiFi, and lets them refresh fast enough for persistence-of-vision tricks.

Open the example in the editor See the calls

Built in on Mokxi: #include <Adafruit_DotStar.h> and it builds, with nothing to install. Free, and no account needed.

## What Adafruit DotStar does

The calls match Adafruit_NeoPixel closely: begin(), setPixelColor(), fill(), setBrightness(), show(), Color(), ColorHSV() and gamma32(). The constructor differs. It takes the number of LEDs, the data pin, the clock pin and the color order, which for most APA102 strips is DOTSTAR_BRG. Leave the pins out and the library uses the board’s hardware SPI pins, which is faster still.

Be clear on what Mokxi does with it: the library compiles and runs, and show() clocks the real APA102 frames out on the two pins, so a logic analyzer shows them. But there is no APA102 part yet, so no LED lights, and begin() says so on the Serial Monitor. For a strip you can watch, use the WS2812 part with Adafruit_NeoPixel, whose calls are nearly the same.

Library Manager name | Adafruit DotStar

Author | Adafruit

Include | #include <Adafruit_DotStar.h>

Boards | every board Mokxi compiles for

In the simulator | Builds and runs, and says plainly that the hardware behind it is not simulated.

## Install it

It builds on every board Mokxi compiles for.

In Mokxi it is built in: #include <Adafruit_DotStar.h> and the sketch compiles, with no download, no zip and no Library Manager.

On a real board, install "Adafruit DotStar" by Adafruit from the Arduino IDE’s Library Manager (Sketch, Include Library, Manage Libraries), or add Adafruit DotStar to lib_deps in PlatformIO. Mokxi follows the calls of release 1.2.5, so a sketch written here builds there too.

What to know in the simulator: Mokxi has no APA102 part yet. show() still clocks the real frames out on the two pins (or SPI), so a logic analyzer shows them, but no LED lights; begin() says so. The WS2812 part with Adafruit_NeoPixel.h is the simulated strip.

- ESP32-C3
- Arduino Uno
- Arduino Nano
- Arduino Mega 2560
- Arduino Leonardo
- SparkFun Pro Micro
- Arduino Micro
- ESP32-C6
- WCH CH32V003
- ATtiny85
- Raspberry Pi Pico
- Raspberry Pi Pico W
- Seeed XIAO SAMD21
- STM32
- STM32 Nucleo-F411RE
- STM32 Blue Pill
- micro:bit V2
- Arduino Uno R4
- ESP32 DevKit
- ESP32-S3-DevKitC-1
- ESP8266 NodeMCU
- Arduino Pro Mini 3.3 V
- Seeed XIAO ESP32-C3
- ESP32-C3 SuperMini
- Seeed XIAO ESP32-C6
- ESP32-DevKitC V4
- LOLIN32 Lite
- Wemos D1 R32
- Cheap Yellow Display
- TTGO T-Display
- Seeed XIAO ESP32-S3
- Arduino Nano ESP32
- Arduino Nano RP2040 Connect
- Seeed XIAO RP2040
- Waveshare RP2040-Zero
- Arduino Uno R4 WiFi

## The calls you will use

In the order a sketch meets them.

### Adafruit_DotStar strip(30, 4, 5, DOTSTAR_BRG)

Thirty LEDs with data on pin 4 and clock on pin 5. Leave the two pins out to use hardware SPI on MOSI and SCK.

### strip.begin()

Sets the pins or SPI up. Follow it with show() to turn every LED off at power-up.

### strip.setPixelColor(head, 0xFF0000)

Sets one LED in the buffer, as a packed 0xRRGGBB number or as three values for red, green and blue.

### strip.fill(strip.Color(0, 0, 64), 0, 10)

Sets a run of LEDs, here the first ten, to one color. With no count it fills to the end.

### strip.setBrightness(32)

Scales every color down, 0 to 255. Useful on a USB supply, where a long strip at full white is far too much current.

### strip.show()

Clocks the start frame, each LED’s four bytes and the end frame out to the strip.

### strip.ColorHSV(hue)

A color from a 16-bit hue, 0 to 65535 around the wheel. Pass it through gamma32() for fades that look even.

## Example: A DotStar strip chaser (strandtest)

On the Arduino Uno R3. It runs in the browser exactly as printed.

sketch.ino · Arduino Uno R3

Open it in the editor, wired and ready to run

## Common errors and how to fix them

### Red shows as blue or green

The color order argument does not match the LEDs. Try DOTSTAR_BRG first, then DOTSTAR_RGB or DOTSTAR_GRB until setPixelColor(0, 0xFF0000) lights red.

### no APA102 (DotStar) strip is simulated, printed by begin()

That is the simulator telling you the frames go to the pins but no part shows them. The sketch is fine; to see LEDs light in Mokxi, switch to Adafruit_NeoPixel with the WS2812 part.

### The strip shows random colors far down its length

The clock and data wires are swapped, or the strip is longer than the count in the constructor. Check the pin order (data first, then clock) and set the real number of LEDs.

## Keep going

### Learn

- Arduino NeoPixel (WS2812B): Wiring and Code

### More leds libraries

- Arduino_LED_Matrix (Uno R4 core)
- Adafruit NeoPixel
- FastLED
- Adafruit NeoMatrix
- NeoPixelBus by Makuna
- WS2812FX

Every built-in library · Open the editor

## Try Adafruit DotStar without installing anything

Open the example, change the sketch, and keep your version in a free account.

Start building free

Open the editor
