WS2812B LEDs


The WS2812B LED consists of three light-emitting diodes: red, green and blue (RGB). By combining these three colors at different intensities, up to 16,581,375 colors can be displayed.

These LEDs have a built-in RGB controller and communicate via a specific serial protocol, enabling a large number of WS2812B LEDs to be daisy-chained and each one individually controlled.

Numerous WS2812B LEDs can therefore be connected in series, using just one microcontroller output to control them individually.


The WS2812B LED is connected by 4 pins :

  • 5V power supply,
  • Mass,
  • Input command (Din),
  • Output command (Dout).

Principle of operation

To control an LED, a three-byte signal (frame) is required (one byte per color) to define the desired color level between 0 and 255. Each additional LED to be controlled adds a 24-bit word (3 bytes) to the frame.

The first LED will "consume" the first three bytes to define its lighting level, and leave the following bytes for the LED connected to the Dout output. In this way, each LED uses 3 bytes and allows the following bytes to pass. It is therefore possible to switch on a particular LED in the strip without necessarily switching on the others.

A strip can be made up of several hundred LEDs.

A microcontroller can control several strips (using one output per strip).

Possible uses for model railways

  • lighting of the scene filmed by a camera (WACAM-N on-board camera project);
  • lighting of a dark area of the network;
  • lighting inside a building;
  • simulate the reflections emitted by a TV set operating in a building (random color variation);
  • possibility of progressive lighting (ascending or descending);
  • available in the form of a strip several meters long that can be cut to create lighting effects;
  • etc.

Diagram of connection of a strip of LEDs

The microcontroller's output pin is directly connected to U1's DIN pin, enabling control of the entire strip. Capacitors next to each LED absorb interference (104 = 100nF).