PinDescriptionPinDescription
GNDGroundDOUTData Output to next LED
DINData InputVDD5 volt power supply

WS2812, SK6812, and ‘NeoPixel’ RGB LEDs are all controlled by the same single-wire, time-based protocol. Multiple LEDs can be chained together, with the DOUT of one LED connecting to the DIN of the next.

Protocol

The WS2812 protocol is a single-wire, time-based protocol. The data is sent as a series of 24-bit RGB values, with each color represented by 8 bits. The data is sent in the order of green, red, and blue (GRB).

Single wire protocols like the WS2812 are generally time based. 0 is encoded as a short high followed by a long low. 1 is encoded as a long high followed by a short low. The timing of the high and low signals is critical to the operation of the protocol.

Each LED in the chain receives data and passes it on to the next LED. A >280us low signal, called reset, must separate each LED update.

Images via datasheet.

Connections

Many strips of WS2812s come with connectors already soldered for external power and data. You may need to pull back the heatshrink over the connector wires to determine the pinout.

Our strip has a 3 pin data connector with +5volts, data, and ground. Two additional wires are available for external power, which we connected to a screw terminal barrel jack socket.

External power

External 5 volt power supplyWS2812Description
+5 voltsVDDPower to the WS2812
GNDGNDGround connection to the WS2812

If your strip is very small (<5 LEDs), you can get away with powering the LEDs from the Bus Pirate VOUT pin.

Data

Bus PirateWS2812Description
SDODINData from Bus Pirate to first LED
GNDGNDA ground connection is required

Connect the Bus Pirate SDO pin to the WS2812 DIN wire, and Bus Pirate ground to WS2812 ground.

Setup

Bus Pirate [/dev/ttyS0]
HiZ> m led

Mode: LED
LED type
 1. WS2812/SK6812/'NeoPixel' (single wire interface)*
 2. APA102/SK9822 (clock and data interface)
 3. Onboard LEDs (18 SK6812s)
 x. Exit
Type (1) > 1
LED-(WS2812)> W 5
5.00V requested, closest value: 5.00V
300.0mA requested, closest value: 300.0mA

Power supply:Enabled
Vreg output: 5.0V, Vref/Vout pin: 5.0V, Current: 2.6mA

LED-(WS2812)> 

Setup is easy, enter LED mode and enable a 5 volt power supply.

  • m led - set the Bus Pirate to LED mode, choose WS2812 as the interface type
  • W 5 - set the onboard power supply to 5 volts to power the Bus Pirate buffers

See it in action

Green, red, blue

Bus Pirate [/dev/ttyS0]
LED-(WS2812)> [ 0xff0000 0x00ff00 0x0000ff

RESET
TX: 0xFF0000.24 0x00FF00.24 0x0000FF.24 
LED-(WS2812)> 

Let’s light the first three LEDs in the chain. The first LED will be green, the second red, and the third blue.

  • [ - WS2812 data frames start with a reset (>280us low), [ sends reset in LED/WS2812 mode.
  • 0xff0000 - set the first WS2812 to green/full brightness
  • 0x00ff00 - set the second WS2812 to red/full brightness
  • 0x0000ff - set the third WS2812 to blue/full brightness

Purple

Bus Pirate [/dev/ttyS0]
LED-(WS2812)> [ 0x00FFFF:3

RESET
TX: 0x00FFFF.24 0x00FFFF.24 0x00FFFF.24 
LED-(WS2812)> 

Next let’s mix colors to make all three LEDs purple.

RGB cycle

Bus Pirate [/dev/ttyS0]
LED-(WS2812)> [0xff0000:3  D:500 [0x00ff00:3 D:500 [0x0000ff:3

RESET
TX: 0xFF0000.24 0xFF0000.24 0xFF0000.24 
Delay: 500ms
RESET
TX: 0x00FF00.24 0x00FF00.24 0x00FF00.24 
Delay: 500ms
RESET
TX: 0x0000FF.24 0x0000FF.24 0x0000FF.24 
LED-(WS2812)> 

We can use the Bus Pirate delay command to create a simple RGB cycle.

  • [ - WS2812 data frames start with a reset (>280us low), [ sends reset in LED/WS2812 mode.
  • 0xff0000:3 - set three WS2812s to green/full brightness.
  • D:500 - delay 500ms.
  • [ 0x00ff00:3 D:500 - set three WS2812s to red/full brightness, delay 500ms.
  • [ 0x0000ff:3 - set three WS2812s to blue/full brightness.

White

Bus Pirate [/dev/ttyS0]
LED-(WS2812)> [ 0xffffff:3

RESET
TX: 0xFFFFFF.24 0xFFFFFF.24 0xFFFFFF.24 
LED-(WS2812)> 

To aproximate white, we can set all three colors to full brightness.

Off

Bus Pirate [/dev/ttyS0]
LED-(WS2812)> [ 0x000000:3

RESET
TX: 0x000000.24 0x000000.24 0x000000.24 
LED-(WS2812)> 

To turn off the LEDs, we can set all three colors to 0.