Learn How to Interface W2812B LED Strip with Arduino

Hello Electronics Lovers in this article I will show you how to interface W2812B LED Strip with Arduino Mini Pro in just a few simple steps. Have you ever seen those Colorful Magic LED lights glowing randomly with different color patterns outside Restaurant, party, Shops or Public Parks during Night?  If yes then you must be waiting for an answer that how it works, i assume, those who are reading this article must be familiar with Basic Electronic Skills before knowing the answer.Related image

LED stands for Light Emitting Diode, this is one of the most famous types of Diode. Working principle of the LED is simple, it will Glow whenever it gets sufficient DC voltage as an input just to move out the free electron from its valence shell ( Google it if you want to know more about How LED works), Most of the time it requires 3.5-4V DC as an input.  You can get easily all kind of LEDs in multiple colors such as RED, GREEN, YELLOW, BLUE or ORANGE from your nearest shop who sells Electronic Component.

To embed more than one LED in a single strip is known as LED strip, in the present market different kind of LED strips available with different specification and properties. In our project, we have used W2812B LED Strip due to these reasons:

  • Water Proof ( You can easily use W2812B LED Strip for the outdoor project )
  • 60 LED per meter ( Buy as per your Requirement of the project)
  • Easy to use, Strip include Three wires one is for + other one is for Ground and the last one is for Data.
  • Bulletin option inside strip to choose 5v or 12v DC as an input power source.
  • Excellent light intensity + More brightness for a long time.

Material needed for this Project:

  1. W2812B LED Strip 120 LED per Two meter
  2. 5v/3A DC Power Supply for the LED Strip ( Do not Exceed the input voltage or Read the manual for more accurate details)
  3.  Arduino Mini Pro
  4. Jumper Wires

W2812B LED Strip

Here is the W2812B 5050 LED Strip I bought online, W2812B (3pins) is a newer generation and W2812(4 pins) is older generation. You may select the LED voltage (5V or 12V) of your preference as long as you have a suitable power source.

Hardware Setup:

 A simple setup and circuit description are given below:

  • Connect PIN no 6 of the Arduino Pro Mini to Data pin of W2812B Led Strip
  • Arduino +5V to power source 5V
  • Arduino GND to power source GND
  • W2812B +5V to +5V power 5V/3A adapter (Power needed depends on how many LED you hookup)
  • W2812B GND to power 5V/3A adapter GND
  • Arduino GND to W2812B GND

W2812B Led Strip In Action :

 W2812B Led Strip Library and Source Code :

 Before Going to upload a source code into Arduino Pro Mini by using Arduino IDE, it is necessary to Download required LED strip library first and paste inside Arduino libraries folder. Kindly Click here to Download W2812B Led Strip Library  Once you successfully update Library, now its time to Load up the sample code from FastLED library “ColorTemperature”.

You have to change the code to fit your Arduino environment settings:
1. LED_PIN = I use pin 6
2. NUM_LEDS = I have 120 in my LED StripHere is the source code:

 


#include <FastLED.h>
 
#define LED_PIN     6 // Data pin
 
// Information about the LED strip itself
#define NUM_LEDS    120 //Number of LED in the whole spripe
#define CHIPSET     WS2811
#define COLOR_ORDER GRB
CRGB leds[NUM_LEDS];
 
#define BRIGHTNESS  128
#define TEMPERATURE_1 Tungsten100W
#define TEMPERATURE_2 OvercastSky
 
// How many seconds to show each temperature before switching
#define DISPLAYTIME 20
// How many seconds to show black between switches
#define BLACKTIME   3
 
void loop()
{
  // draw a generic, no-name rainbow
  static uint8_t starthue = 0;
  fill_rainbow( leds + 5, NUM_LEDS - 5, --starthue, 20);
 
  // Choose which 'color temperature' profile to enable.
  uint8_t secs = (millis() / 1000) % (DISPLAYTIME * 2);
  if( secs < DISPLAYTIME) {
    FastLED.setTemperature( TEMPERATURE_1 ); // first temperature
    leds[0] = TEMPERATURE_1; // show indicator pixel
  } else {
    FastLED.setTemperature( TEMPERATURE_2 ); // second temperature
    leds[0] = TEMPERATURE_2; // show indicator pixel
  }
 
  // Black out the LEDs for a few secnds between color changes
  // to let the eyes and brains adjust
  if( (secs % DISPLAYTIME) < BLACKTIME) {
    memset8( leds, 0, NUM_LEDS * sizeof(CRGB));
  }
  
  FastLED.show();
  FastLED.delay(8);
}
 
void setup() {
  delay( 3000 ); // power-up safety delay
  // It's important to set the color correction for your LED strip here,
  // so that colors can be more accurately rendered through the 'temperature' profiles
  FastLED.addLeds(leds, NUM_LEDS).setCorrection( TypicalSMD5050 );
  FastLED.setBrightness( BRIGHTNESS );
}

Watch Video :

Image and video Courtsey: https://stonez56.blogspot.tw/2015/06/test-arduino-and-w2812b-led-strip.html


Posted

in

by

Tags:

Comments

One response to “Learn How to Interface W2812B LED Strip with Arduino”

  1. Juliana Maçaneiro Avatar
    Juliana Maçaneiro

    Hi

    I’m Brazilian, sorry for my English.
    I have a doubt.
    You say #define CHIPSET WS2811, but the strip is WS2812b.
    Is there any difference?
    I’m having trouble controlling this track.

Leave a Reply

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