Arduino Addressable LEDs & Splendid Projects

Today, we’re going to explore the uses of addressable LEDs. Addressable LED is an easy way to add complex lighting effects to any project. Each addressable LED has an integrated driver that allows you to control the color and brightness of each LED independently. The combined LED/driver chip on the LED is the extremely compact WS2812B – an improved WS2811 LED driver integrated directly into a 5050 RGB LED – which enables higher LED densities. On the right of the picture, you can see the integrated driver and the bonding wires connecting it to the green, red, and blue LEDs, which are on at their dimmest setting.



WS2812 neopixels are addressable RGB LEDs. The integrated controller chip allows you to change the color of the LED and address each individual LED. The WS2812 comes in two versions (WS2812 & WS2812B), and the most evident difference between the two types is pin configuration and internal structure. The WS2812 has 6 pins and 6 pads on the inside, while the WS2812B has 4 pins and 4 internal pads. WS2812B structure is optimized to reduce short circuiting, reduce heat production and allow fast heat loss. The WS2812 and WS2812B power and control signal connection is the same. The power and ground (+5v & gnd) go to the power and ground pins/pads and the control signal goes to the data pin/pad (Din & Dout). When connecting the signal you must ensure that the incoming signal is connected on the data in pin (Din) and the outgoing signal on the data out (Dout) pin. But, you can fed power to the WS2812B from any direction. Here we are using the type WS2812B (bought from eBay) for our little experiments!


Typical specifications of WS2812B is shown below. One thing to remember when powering an addressable LED strip (not a single one) in your project is that you should ensure that a separate power supply is reserved for the strip (do not take it from the basic low-current microcontroller power supply). When connecting the LEDs in parallel (you can power it from any direction) always start connecting the ground (gnd) before you connect the live (5v) power pin. There is so much you can do with WS2812B addressable LEDs once you learn the basics. However, always remember to choose the correct micro controller (or arduino board) based on the RAM requirements of your project.
– Voltage: 5V – 7V
– Current: 60 mA
– RAM: 3bytes

WS2812B & Arduino

Earlier we controlled LED matrixes, strips and other complex LED projects bundled with countless interconnected wires with the help of multiplexers and shift registers. Now it is easy for us to control big LED fixtures without extra circuitry and discrete components using addressable LEDs (neopixels). Here is a small demonstration changing color of the addressable LED WS2812B. Hardware and software for this single WS2812B experiment is given below. Before uploading the code (sketch) to Arduino, make sure you download the Adafruit Neopixel Library ( and use some of the example sketch to practice. You can also download the library (Adafruit_NeoPixel-master) through the download link included below.

Adafruit_NeoPixel-master (D6 of Arduino connected to Din of WS2812B)

(D6 of Arduino connected to Din of WS2812B)

It is highly recommended to connect a 100nF capacitor across the ‚5v and Gnd‛ connection, and a 100-470 Ohm resistor in series with the ‚Din‛ line of the WS2812B. Fortunately, WS2812B used here have these two components pre-attached; see R1 (75R) and C1 (100n) in our WS2812B module. Here is a well prepared code for addressable LED strips/rings, good for experiments with a single WS2812B “neopixel-compatible” addressable LED, too!

download the sketch
  #include <Adafruit_NeoPixel.h>  #define PIN 6  // Parameter 1 = number of pixels in strip  // Parameter 2 = pin number  // Parameter 3 = pixel type flags, add together as needed:  // NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)  Adafruit_NeoPixel strip = Adafruit_NeoPixel(1, PIN, NEO_GRB + NEO_KHZ800);  void setup() {     strip.begin();; // Initialize all pixels to 'off'  }  void loop() {     // Some example procedures showing how to display to the pixels:     colorWipe(strip.Color(255, 0, 0), 50); // Red     colorWipe(strip.Color(0, 255, 0), 50); // Green     colorWipe(strip.Color(0, 0, 255), 50); // Blue     // Send a theater pixel chase in...     theaterChase(strip.Color(127, 127, 127), 50); // White     theaterChase(strip.Color(127, 0, 0), 50); // Red     theaterChase(strip.Color( 0, 0, 127), 50); // Blue     rainbow(20);     rainbowCycle(20);     theaterChaseRainbow(50);  }  // Fill the dots one after the other with a color  void colorWipe(uint32_t c, uint8_t wait) {     for(uint16_t i=0; i<strip.numPixels(); i++) {        strip.setPixelColor(i, c);;        delay(wait);     }  }  void rainbow(uint8_t wait) {     uint16_t i, j;     for(j=0; j<256; j++) {        for(i=0; i<strip.numPixels(); i++) {           strip.setPixelColor(i, Wheel((i+j) & 255));        };        delay(wait);     }  }  // This makes the rainbow equally distributed throughout  void rainbowCycle(uint8_t wait) {     uint16_t i, j;     for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel        for(i=0; i< strip.numPixels(); i++) {           strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));        };        delay(wait);     }  }  //Theatre-style crawling light  void theaterChase(uint32_t c, uint8_t wait) {     for (int j=0; j<10; j++) { //do 10 cycles of chasing        for (int q=0; q < 3; q++) {           for (int i=0; i < strip.numPixels(); i=i+3) {               strip.setPixelColor(i+q, c); //turn every third pixel on            };         delay(wait);         for (int i=0; i < strip.numPixels(); i=i+3) {            strip.setPixelColor(i+q, 0); //turn every third pixel off         }         }     }  }  //Theatre-style crawling light with rainbow effect  void theaterChaseRainbow(uint8_t wait) {     for (int j=0; j < 256; j++) { // cycle all 256 colors in the wheel        for (int q=0; q < 3; q++) {           for (int i=0; i < strip.numPixels(); i=i+3) {               strip.setPixelColor(i+q, Wheel( (i+j) % 255)); //turn every third pixel on            }  ;            delay(wait);            for (int i=0; i < strip.numPixels(); i=i+3) {               strip.setPixelColor(i+q, 0); //turn every third pixel off            }         }     }  }  // Input a value 0 to 255 to get a color value.  // The colours are a transition r - g - b - back to r.  uint32_t Wheel(byte WheelPos) {     if(WheelPos < 85) {         return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);      } else if(WheelPos < 170) {         WheelPos -= 85;         return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);      } else {         WheelPos -= 170;         return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);      }  }  

Test Video

(proof of concept – from author’s lab)

(proof of concept – from author’s lab)

More Projects

It is possible to drive a number of addressable LEDs using just one microcontroller pin as shown here. So you can build your own LED strips, rings, ornaments, etc by combining more LEDs as you wish. In case of multiple LEDs, first of all connect the microcontroller’s pin to the Din of the first LED, Dout of this LED to the Din of the next LED, and repeat this wiring for ‘n’ LEDs. One thing to remember when doing this is that you should use a good external 5V dc power supply for the LEDs. And, when connecting the LEDs, always start connecting the ground before you connect the live power pin. Further, it is necessary to change the parameter // Parameter 1 = number of pixels in strip. For example, if you are using 6 LEDs instead of the 1 LED, then change the line “Adafruit_NeoPixel strip = Adafruit_NeoPixel(1, PIN, NEO_GRB + NEO_KHZ800);” as “Adafruit_NeoPixel strip = Adafruit_NeoPixel(6, PIN, NEO_GRB + NEO_KHZ800);“.