WS2812B Pinout: A Complete Guide to Programming Your LED Strip

FACTS CHECKED BY  Bob Smith

Colorful lighting is important in several electronic applications and amplification circuits. These application circuits often require different types of effects. The WS2812B pinout is an intelligent control LED package for excellent display effects in this use case.

Large installations may require ~300-400 LED strips, depending on the purpose. In that case, you need an ATmega328P-based microcontroller or other AVR-based microcontrollers like Arduino Uno, Arduino Mega, RaspberryPi, etc. Therefore, this guide takes you through the necessary connection and installation processes.

WS2812B Introduction

WS2812B is a smart RGB LED board with a control unit embedded into the 5050 package type. Typically, they are addressable LED strips that let a microcontroller control each LED light source to display amazing effects.

Features and Specifications

  • There is an embedded power and electric reset circuit.
  • It has protection against reverse bias voltage from the power supply.
  • There is a standard reshaping circuit built in to prevent signal distortions.
  • The WS2812B power supply feeds the RGB LED and the control circuit.
  • Also, it uses a single-line interface for transmission signals via the cascading port.
  • The refresh rate is 20fps while cascading numbers are below 1024.
  • The data package sending speed is 800Kbps.
  • The LED light is consistent and affordable.
A color palette

(A color palette)

WS2812B Pinout

Pin No.Pin NameFunction
1VCC/VDDIt serves as the supply voltage pin for the LED.
2DOUTThis output pin supplies the input data signal.
3VSS/GNDIt is the ground pin. It has a 0V reference supply voltage.
4DINOn this side is the input pin for the output data signal.

Alternate Options

  • APA102-based LEDs.
  • WS2813-based LED boards.
  • WS2812-based boards.

How Does WS2812B Work?

Most times, the WS2812B strip of boards has an integrated control circuit and the RGB chip in the package of 5050 components. The string strips contain four pins – VCC, Ground, DIN, and DOUT.

The WS2812B labels on the strip indicate a signal reshaping circuit and digital latch. It also includes an electric and a power-lost reset circuit. In addition, the labels on the strip show data transfer protocol use a single-line NZR communication mode.

First, the DIN gets data from the controller after the power-on reset.  The pixel then collects the 24 Byte data and transfers it to the data latch for the internal circuit and the next pixel before it goes out of the DOUT port.

WS2812B RGB LED Internal Components

5050 LED IC (a serial programmable chip), the RGB LED, and the LED strip pigtail connector.

WS2812B Addressable Serial Controller

Further, the WS2812B IC has an addressable serial controller. It has a serial-in serial-out (SISO) configuration. That is, its 24-bit register takes serial data and stores it. As a result, the controller adjusts the RGB LED color and brightness.

The 24-bit register has three 8-bit parts. They are:

  • R0-R7
  • G0-G7
  • B0-B7.

Each of these RGB parts contains intensity values ranging from 0 to 7. For example, Red, Green, or Blue with a higher value displays darker hues.

How To Use WS2812B Addressable RGB LEDs?

First, connect the GND and VCC pin to all the LEDs. The first and second LED strips must connect to the signal source or microcontroller via DIN. The data input signals must be precise for WS2812-based LEDs to function well. Note that the IC uses PWM to clarify the zeroes and ones. We call this operation Settling Time.

So, to properly time your addressable LED strips, you must assign 24 bits per LED strip. After sending a packet of data, give a blank pulse lasting 50 microseconds. This break allows the LED strip to recover and send the second data series.

  • The Connection between WS2812B and Arduino

Here, we use the Arduino output pin to connect the WS2812B LED according to its power requirements. We connect 8 LEDs with the Arduino’s output pin using a three-pin JST SM connector. In any case, high-density strips of LED need an external power source connected via wire pigtails.

So, start with a connection between the Arduino 5V power source and the WS2812B LED strip. Next, connect the Arduino ground pin to the LED ground pin, especially when using an external power supply. Finally, connect the LED strip’s data pin with pin 3 of the Arduino Uno.

WS2812B LED strip connected to a microcontroller board

(WS2812B LED strip connected to a microcontroller board).

WS2812B Pinout: WS2812B Arduino Code

For this purpose, the FastLED library is important for writing the WS2812B Arduino code. So, go ahead to the GitHub page of FastLED and download it into the Arduino folder.

WS2812B Pinout: After installation:

  1. Search “FastLED” in the library manager.
  2. Choose the appropriate library to install.
  3. Restart your Arduino IDE afterward for the new installation to reflect.
  4. Run your code!
  • Setting RGB Colors

Setting the RGB colors of the LED has different methods. One of the famous methods is in the example below:

leds[i].r = 50;

leds[i].g = 100;

leds[i].b = 150;

The code above sets individual colors of red, green, and blue with different brightness values. Otherwise, set them all at once:

leds[i] = CRGB(50, 100, 150);

WS2812B Pinout: Create Different Types of Effects

This area lets you create different effects with a function and loop them. Check out these functions to use your Arduino code.

Installation of an LED strip on a cabinet

(Installation of an LED strip on a cabinet)

  • WS2812B Pinout: FastLED Color Palette

A color palette is a table mapping RGB colors between 0 to 255. Color palettes are of the older 16-color type and the newer gradient type. For the gradient palette, you define it with a code found at Fast led Library.

  • WS2812B Pinout: Filling Multiple LEDs with a Palette

In most cases, the function “fill_palette” helps you fill multiple LEDs with a palette. Choosing a start index is one of the arguments you need to specify in your code. For example, a start index of 20 chooses all colors from 20 to 255. Other arguments include

fill_palette (LEDs, needs, incIndex, brightness, Palette, blend type);

WS2812B Addressable RGB LED Applications

  • Indicator LED.
  • Indoor/outdoor LED.
  • Decorative displays.
  • RGB LED strip.
  • Backlighting.
  • Video irregular screen.
  • General-purpose illumination.
LED strip lighting on the ceiling

(LED strip lighting on the ceiling)

Conclusion

In conclusion, the WS2812B addressable RGB LED strips rely on a microcontroller like Raspberry Pi or Arduino for power supply and control. Some of these daisy-chaining LED strips feature awesome color palettes, excellent display effects, and protection from water jets and dust.

Now that we know all about the WS2812B LED, what is next is to try it out in an Arduino project. Should you still have any questions, feel free to contact us.

Need custom LED services?