WS2812 Breakout Hookup Guide

Contributors: Jimb0
Favorited Favorite 5

WS2812 Overview

The WS2812 is much more than meets the eye. It may look like a common 5050-sized (5x5mm) LED, but there’s actually an integrated circuit embedded inside there too. If you look really hard, you can see the tiny black chip hidden in there, along with minuscule gold wires connecting the chip to the LED.

Zoom in on the IC

Pretty nifty view at the guts of the WS2812.

The LED itself is like any RGB (Red/Green/Blue) LED. The brightness of each color can be adjusted using pulse-width modulation to one of 256 different levels. That means there are 16,777,216 (2563) possible combinations of colors. You can produce any color from white to black (off), or salmon to sienna.

Breakout Board Pinout

The Breakout board mounts that multi-taltented LED onto a PCB, and breaks out the few pins required to control the LED.

Annotated WS2812 Breakout pinout

Four unique pins are broken out:

  • 5V – This should be a regulated supply voltage between 5V and about 7V. More than that could harm the LED, less than 5V will either reduce brightness, or it just won’t turn on.
  • GND – The common, ground, 0V reference supply voltage.
  • DI – Data from a microcontroller (or another WS2812 pixel) comes into this pin.
  • DO – Data is shifted out of this pin, to be connected to the input of another pixel or left floating if it is the last link in the chain.

Data Transmission Interface

Note: this stuff is ugly, and not critical to understand if you just want to use the breakout board. (That’s what libraries are for, right?!) It’s interesting to talk about, because the interface is so unique.

The communication interface between a microcontroller and the WS2812 is weird. It’s one wire, but it’s not like a standard, UART serial interface. This interface is very time-specific. Both a logic 0 and a logic 1 require a square pulse, and it’s the length of the pulse that defines which it is.

Data code chart

Timing diagram for a single bit of value 0 or 1.

The data is sent in a sequence containing 24 of those bits – 8 bits for each color – followed by a low “reset” pulse of at least 50µs.

Data bit order

A sequence of 24 timed-bits sets the color for each channel. 8-bits per channel. Green first, then red, then blue.

The larger the value of a specific color is, the brighter it will be. If every color is set to 0, the LED will be off. If every color is set to max – 255 – the LED will be as bright and white as can be.

This is all to say that the interface is very time-specific. To run the LEDs you’ll need a real-time processor, like an Arduino; microprocessors like those on the Raspberry Pi or pcDuino can’t give you a reliably-timed pulse. Even if one bit is less than a microsecond off, that could mean the difference between purple and maroon.