Arduino and WS2812b example

WS2812 family 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. 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 24 bit 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

I bought a little breakout, here is a picture of this part

ws2812 rgb led breakout

ws2812 rgb led breakout

Schematics and layout

Here are schematics and layout for connecting one of these breakouts

Arduino and WS2812_bb

Arduino and WS2812_bb

Arduino and WS2812_schem

Arduino and WS2812_schem


You will need to import the Adafruit Neopixel library.

In this example we will flash the WS2812 red, green and blue

#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
  #include <avr/power.h>
// Which pin on the Arduino is connected to the NeoPixels?
#define PIN            6
// How many NeoPixels are attached to the Arduino?
#define NUMPIXELS      1
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
int delayval = 500; // delay for half a second
void setup() 
  pixels.begin(); // This initializes the NeoPixel library.
void loop() {
  // For a set of NeoPixels the first NeoPixel is 0, second is 1, all the way up to the count of pixels minus one.
  for(int i=0;i<NUMPIXELS;i++)
    // pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
    pixels.setPixelColor(i, pixels.Color(0,255,0));;
    pixels.setPixelColor(i, pixels.Color(255,0,0));;
    pixels.setPixelColor(i, pixels.Color(0,0,255));;

10PCS/LOT WS2812 RGB LED Breakout Module For Arduino


Comments are closed.