WS2812B RGB-LED module

WS2812B refers to a special, addressable RGB LED module with an integrated controller. Thanks to this internal chip, the WS2812B only requires a single digital output from the microcontroller (e.g., Arduino). Additionally, the internal controller allows for serial chaining of multiple WS2812B modules.
The WS2812B is available both as a single module and in the form of strips, rings, matrices (e.g., 4x4, 8x8), and other configurations. Sometimes this module is also called "NeoPixel".

A single WS2812B RGB-LED module (Package 5050)
Fig.: A single WS2812B RGB-LED module (Package 5050)

Features/Specifications

IC type: WS2812B (Integrated control circuit and RGB chip)
Package: 5050 SMD (5mm x 5mm)
Operating voltage: 3.3V to 5V (typically 5V)
Current consumption: ~36mA per LED at full brightness (12mA per color channel)
Color depth: 24-bit (8-bit per RGB channel, 256 brightness levels)
Total colors: 16777216 (256×256×256)
Data frequency: 800 kHz
Pulse width (0/1): 0: 36% duty cycle, 1: 64% duty cycle (1.25μs total, ±150ns tolerance)
PWM frequency: ~400 Hz per color channel

📄 WS2812B RGB-LED module datasheet (431 kB)

Connections

Terminal diagram of the WS2812B RGB-LED module
Fig.: Terminal diagram of the WS2812B RGB-LED module
WS2812B Description
5V (also: VCC or VDD) Power supply with +3.5V ~ +5.3V
GND (also: VSS) Ground connection
DI or DIN "Data In": Data input signal (connects to the microcontroller)
DO or DOUT "Data Out": Data output signal (can be connected to DI of the next WS2812B)

Used Components

Setup & Programming

Each WS2812 module requires up to 60mA and should be protected by a decoupling capacitor. A series resistor is also placed in front of the data input.

Circuit diagram for connecting a WS2812B RGB-LED with a microcontroller
Fig.: Circuit diagram for connecting a WS2812B RGB-LED with a microcontroller

Simple Color Test

Arduino Uno

The following sketch demonstrates cycling through the primary colors of the LED module one after another. The Adafruit_NeoPixel library is used to control the RGB module. Note that when creating the Adafruit_NeoPixel object, the constant NEO_GRB is used to ensure the correct color order for the LED. This may vary from module to module and might require experimentation.

#include <Adafruit_NeoPixel.h>

#define LED_PIN    9  // or any other PWM capable pin
#define BRIGHTNESS 50 // [1..255]
#define DEMO_DELAY 1000

Adafruit_NeoPixel ledModule = Adafruit_NeoPixel(1, LED_PIN, NEO_GRB + NEO_KHZ800);

void setup() {
    ledModule.begin();

    // set the LED off
    ledModule.setPixelColor(0, ledModule.Color(0, 0, 0));
    ledModule.show();
}

void loop() {
    ledModule.setPixelColor(0, ledModule.Color(BRIGHTNESS, 0, 0));
    ledModule.show();
    delay(DEMO_DELAY);

    ledModule.setPixelColor(0, ledModule.Color(0, BRIGHTNESS, 0));
    ledModule.show();
    delay(DEMO_DELAY);

    ledModule.setPixelColor(0, ledModule.Color(0, 0, BRIGHTNESS));
    ledModule.show();
    delay(DEMO_DELAY);
}
Last edited by Christian Grieger on 2025-05-17
X
  1. [top]
  2. Features/Specifications
  3. Connections
  4. Used Components
  5. Setup & Programming