Random Nerd Tutorials

Guide for WS2812B Addressable RGB LED Strip with Arduino


This post is about the WS2812B LED strip, which is an addressable RGB LED strip. The information in this post also works with other similar LED strips, such as strips of the WS28XX family, Neopixel strip and others.

Introducing the WS2812B LED Strip

The WS2812B addressable LED strip comes in several varieties that differ in size, sealant or LED density. Choose the one that best fits your purposes. 

Where to buy?

You can visit Maker Advisor and find the WS2812B RGB LED Strip best price.

In the following figure you can see my WS2812B LED strip. It is 5 meters long and the LEDs are enclosed in a weatherproof silicone. So, they can be left outside at the rain and dust without any problem.


In my opinion, this is the coolest type of LED strips. You can control the brightness and the color of each LED individually, which allows you to produce amazing and complex effects in a simple way.

This LED strip is made by WS2812B LEDs wired in series. These LEDs have a IC built right into the LED. This allows a communication via a one-wire interface. This means that you can control lots of LEDs using just one digital pin of your Arduino. 

In the following figure you can see the chip inside the LED. The LED is an RGB LED and works like so.


This kind of strips are very flexible and can be cut to any length you want. As you can see, the strip is divided into segments, and each segment contains one RGB LED.  


You can adjust its size by cutting the strip with a scissors in the right place (the proper places to cut the strip are marked).


These strips come with  connectors  at each end . I’ve decided to cut the connectors, and solder header pins. It’s more handy if you want to connect the strip to an Arduino or to a breadboard.


Powering the WS2812B LED Strip

The LED strip should be powered using a 5V power source. At 5V, each LED draws about 50mA, when set to its full brightness.  This means that for every 30 LEDs, the strip may draw as much as 1.5 A. Make sure you select a power source that matches the strip’s needs.

If you end up using an external supply, don’t forget to connect the power supply ground to the Arduino ground.


In this example, the WS2812B LED strip will be powered using the 5V Arduino pin. In my case, I’m controlling 14 LEDs. Bear in mind that if you want to control many LEDs, you’ll need to use an external power supply.


Useful tips:

  • Connect a capacitor with a capacitance between 100uF and 1000uF from power to ground to smooth out the power supply.
  • Add a 220 or 470 Ohm resistor between the Arduino digital output pin and the strip data input pin to reduce noise on that line.
  • Make your wires between the arduino, power supply and the strip as short as possible to minimize voltage loss.
  • If your strip gets damaged and doesn’t work, check if the first LED is broken. If so, cut it, resolder the header pins, and it should be working again.


To control the WS2812B LED strip, you’ll need to download the FastLED library.

Installing the FastLED library

  1. Click here to download the FastLED library. You should have a .zip folder in your Downloads folder
  2. Unzip the .zip folder and you should get FastLED-master folder
  3. Rename your folder from FastLED-master to FastLED
  4. Move the FastLED folder to your Arduino IDE installation libraries folder
  5. Finally, re-open your Arduino IDE

After installing the needed library, upload the following code to your Arduino board (this is an example sketch provided in the library examples folder). Go to File > Examples > FastLED > ColorPalette or copy the code below.

Note: you have to change #define NUM_LEDS to the number of LEDs that your strip currently has, in this example it was 14 LEDs.


In the end, this is what you’ll have. Amazing effects like this one:


And this one:


And this one:


And so on (…)

Using an LED Strip Case

These strips usually come with a removable tape, so that you can stick them wherever you want. The problem is that they don’t stick very well, so chances are that you’ll find your strip in the floor the following day.

The solution: I found this strip case that diffuses the light well and you can screw it to a shelf, for example, if you want a permanent solution. 


Wrapping Up

I hope you’ve found this guide useful.

If like this post, you may also like the following ones:

Thanks for reading.

Recommended Resources

Home Automation using ESP8266 »
Build IoT projects and home automation gadgets with the ESP8266 Wi-Fi module.

Build a Home Automation System »
Learn how to build a automation system using open-source hardware and software from scratch.

Arduino Step-by-Step Projects »
Build 25 cool Arduino projects with our couse even with no prior experience!

Leave a Comment:

Add Your Reply