Shares

Guide for WS2812B Addressable RGB LED Strip with Arduino

Shares

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 buy one here on eBay.

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.

led-strip

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.

led-with-arrow

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.  

sections2

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).

cutting-the-strip

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.

stripheader

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.

Schematics

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.

ws2812b-with-arduino_bb

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.

Code

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.

Demonstration

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

gif1

And this one:

gif2

And this one:

gif3

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. 

foto1

Wrapping Up

I hope you’ve found this guide useful.

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

Thanks for reading,

Rui and Sara

Leave a Comment:

Add Your Reply

Download Home Automation Using ESP8266 (2nd Edition) and Save 30%
Sale Ends January 21

x