Home » ESP32 and WS2812b RGB led example

ESP32 and WS2812b RGB led example

by shedboy71

WS2812 is a intelligent control LED light source that the control circuit and RGB chip are integrated in a package of 5050 components. It internal include intelligent digital port data latch and signal reshaping amplification drive circuit. Also include a precision internal oscillator and a 12V voltage programmable constant current control part, effectively ensuring the pixel point light color height consistent.

The data transfer protocol use single NZR communication mode. After the pixel power-on reset, the DIN port receive data from controller, the first pixel collect initial 24bit data then sent to the internal data latch, the other data which reshaping by the internal signal reshaping amplification circuit sent to the next cascade pixel through the DO port. After transmission for each pixel,the signal to reduce 24bit. pixel adopt auto reshaping transmit technology, making the pixel cascade number is not limited the signal transmission, only depend on the speed of signal transmission.

LED with low driving voltage, environmental protection and energy saving, high brightness, scattering angle is large, good consistency, low power, long life and other advantages. The control chip integrated in LED above becoming more simple circuit, small volume, convenient installation.

These are also called neopixels

Here is the exact module I used, now a lot of documents say 5v but I tried this off 3.3v without an issue, 5v works as well. Double checked a Wemos RGB LED shield and they use 5v as well


esp32 and ws2812

esp32 and ws2812


You need to install the Adafruit neopixel library for this example – You can search for it and add it via the library manager or download it from https://github.com/adafruit/Adafruit_NeoPixel

#include <Adafruit_NeoPixel.h>

#define PIN 15

// When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals.
// Note that for older NeoPixel strips you might need to change the third parameter–see the strandtest
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(1, PIN, NEO_GRB + NEO_KHZ800);

void setup()
pixels.begin(); // This initializes the NeoPixel library.

void loop()

// pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 2; j++) {
for (int k = 0; k < 2; k++) {

pixels.setPixelColor(0, pixels.Color(i * 255, j * 255, k * 255)); // Moderately bright green color.
pixels.show(); // This sends the updated pixel color to the hardware.
delay(200); // Delay for a period of time (in milliseconds).




You can pick these up for under $0.40 per example

New WS2812 RGB LED Breakout module For arduino

You may also like

Leave a Comment

%d bloggers like this:

Adblock Detected

Please support us by disabling your AdBlocker extension from your browsers for our website.