Tutorial – LED-strip

Tutorial – LED-strip

In this tutorial we will learn how to control an addressable RGB LED-strip ( WS2812B or WS2811) using Arduino.

Those are driver circuits for RGB LED. In them are integrated a control circuit and the RGB itselfs.

What is a RGB led?

A RGB is a particular LED made of 3 monocromatics light sources (Red, Green, Blue). By a particular combination of this colors we can obtain all the colors we want.

As you can see you have to connect 4 pins to the Arduino board. One pin is for GND, the other three pins are for RED, GREEN and BLU.

So you have to control each color from a different pin of Arduino. That means that if you want to control some RGB leds, you will have to do a lot of wirings.

How to use WS2811/WS2812b

This two drivers allows you to control a big number of RGB with just 3 wires on your Arduino board (GND, VCC, digital pin for datas). Infact those are usually used in LED-strips or LED-matrices on which there are several LEDs.


This two drivers are different:

  1. The WS2811 has 6 pins and six internal pads while the WS2812B has 4 pins and 4 internal pads.
  2. Lower number of pads means less overheating.

How is made a string

A LED-strip is made by a series of this components. So that means that you have a lot of RGB in series. How many pins do you need? Only three!!

That’s a very important thing, you can control meters and meters of RGB with just three wires because those are addressable RGB LED strip.

Moreover if you want to solder some strings you have to pay attention to the direction in which is oriented the arrow. You have to put them togheter as in figure.

Furthermore you can cut the string to obtain the lenght you want.

Then we have to write a code to control the led-strip.

We explained how they work and the basics about RGB in this article. We suggest to read it before going on with this tutorial.

How to control them with an Arduino

Anyway you now that an RGB is good for creating different colors and also a lot of colors effect.

So now we will learn how to control a LED-strip and make some cool things!


You only need one digital pin from your Arduino. The other two are for VCC and GND. So you can connect them to Arduino or you can use another power supply.

GND on GND – 5V on 5V – Din on pin 10

Once you are done with wirings, you have to upload a code to control the LED-strip.

Arduino Library FastLed.h

First of all you have to add this library to your Arduino IDE. If you don’t know how to do follow this guide, it’s really easy!

When you are done, you can go on with this article.

FastLed.h is a library that will help us controlling the LED-strip. With tha following example you will learn how to adjust the color as you prefer.

Example Code

#include <FastLED.h>         //include the library
#define LED_PIN     10       //write the number of the digital pin that you have used
#define NUM_LEDS    10       //write the number of how many LEDs you will use
#define LED_TYPE    WS2811   //write the type that you are using, comment this line if you are not using WS2811
//#define LED_TYPE    WS2812  //uncomment this line if you are using WS2812
CRGB leds[NUM_LEDS];   //A "CRGB" is an object representing a color in RGB color space. It contains: a one byte value (0-255) representing the amount of red - a one byte value (0-255) representing the amount of green -
a one byte value (0-255) representing the amount of blue in a given color.

void setup()
  FastLED.addLeds<LED_TYPE, LED_PIN, GRB>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );  //initialize in this way in the setup. The arguments of this function are the parameters that we have set before.

void loop()
  for (int i = 0; i < NUM_LEDS; i++) 
    leds[i] = CRGB ( 200, 200, 200);   //set the color you want.
    FastLED.show();                    //this method is used to show the color you set
    delay(40);                         //a delay to have a special effect.

That’s all! Now you are ready for a real project with LED-strips!

Davide Busco

Davide Busco is an engineering student at Federico II University of Naples. He uses his passion and studies to create his projects. He loves be a maker and spread his knowledge. Moreover he has gained the second place in a national makers-tournament between Italian's Universities.

Leave a Reply

Your email address will not be published. Required fields are marked *

en_GBEnglish (UK)
it_ITItaliano en_GBEnglish (UK)
%d bloggers like this: