• Worldwide Shipping

  • 24/7 Customer Support

  • FAQ
  • Worldwide Shipping

  • 24/7 Customer Support

  • FAQ

WS2812B RGB LED strip

INTRODUCTION

Today, everyone is talking about LED strips, and they can be seen in almost every restaurant, cafe, lounge bar, hotel, etc. They are simply pleasing to the eye and why wouldn't you decorate your home this way, or even your room, work desk, shelves, stairs, whatever you like. The intensity of light, reliability, effective energy consumption of the LED technology and the possibilites of different animations and light shows are exactly what makes them so attractive.

 

 

Characteristics:
Color: RGB (red/green/blue)
Voltage: 5V
Power: 16W/m (for white color)
Current: 3.2A/m (for white color)
Number of diodes: 60 diodes per meter
Diode type: WS2812b SMD LED (5050 LED diode with a built-in IC)
Protection: IP20
Dimensions: 10mm width, 2mm thick

HOW DOES IT WORK?

The reason why this LED strip is so special is the way we can control it. WS2812b is the name of an integrated control chip that manages RGB LEDs. What we see on the strip are actually 5050 (5.0 x 5.0 mm) housings. Inside, there are WS2812b IC and 3 leds (red, green and blue). WS2812b IC communicates in a very practical one-wired way using the NZR communication protocol. Each chip has a Din and Dout pin so that it is possible to cascade them into longer series. The strip can be extended in a way that we connect the Dout pin of the previous LED to the Din pin of the next one, but we must pay attention to current consumption, because it can easily become too demanding for the microcontroller.

via GIPHY

COMMUNICATION

The microcontroller constantly sends series of "0" and "1" to data line. WS2812b IC saves the first 24 bits, i.e. 3 bytes (one byte for each color G, R, B)  into latch, and the rest passes further for the next IC and so on to the last pixel. When it reaches the end, the reset code is execuded and everything goes from the beginning.

A BIT MORE OF INTERESTING FACTS

- WS2812B chips have a built-in reversed polarity protection on their strips, i.e. if you accidentally replace +5V and GND, the ICs will not be ruined. However, it is certainly better to check the connection once again.
- Each pixel of three primary colors (R, G, B) can assume 256 (0-255) levels of light, meaning 16 777 216 (256^3) different colors
- ICs have a built-in circuit for constant current that ensures optimal lightness of LEDs

CONNECTING

It is best to supply the strip through an external power supply source, because the microcontroller does not have high output power, but make sure you have a regulated 5V. The same source can be used for Croduino power supply over the +5V pin. Once again, a note, for supplying both Croduino and the strip, you must have a 5V power source, voltages higher than 5.3V can damage Croduino or the strip, and voltages lower than 3.5V will not be sufficient for proper work.

 

ARDUINO CODE

For writing the code, we will use the Adafruit_NeoPixel library. If you are not sure how to install the library, let us remind you with a tutorial on the link.                                                                        First, the LEDs will turn on one by one in red color, then in green, then blue, and ultimately in white. After that goes the rainbow effect. Make sure you try out more interesting animations which come with the library as examples.

 

#include "Adafruit_NeoPixel.h"
#ifdef __AVR__
  #include "avr/power.h"
#endif

// Which Croduino pin is connected to the Data pin of the LED strip
#define PIN 6 

//The first number we turn to the function signifies how many strips does the LED have
//Change if necessary (refers to the first argument)
Adafruit_NeoPixel strip = Adafruit_NeoPixel(60, PIN, NEO_GRB + NEO_KHZ800);  

void setup() {
  strip.begin();
  strip.show();
}

void loop() {
  colorWipe(strip.Color(225, 0, 0), 25); // Red
  delay(500);
  colorWipe(strip.Color(0, 225, 0), 25); // Green
  delay(500);
  colorWipe(strip.Color(0, 0, 225), 25); // Blue
  delay(500);
  colorWipe(strip.Color(225, 225, 225), 25); // White
  delay(500);
  rainbow(40); //dugine boje
}

// Turn on LEDs, one by one, in some color 
void colorWipe(uint32_t c, uint8_t wait) {
  for(uint16_t i=0; i<strip.numPixels(); i++) {
    strip.setPixelColor(i, c);
    strip.show();
    delay(wait);
  }
}

//Rainbow colours function
void rainbow(uint8_t wait) {
  uint16_t i, j;
  for(j=0; j<256*5; j++) {
    for(i=0; i< strip.numPixels(); i++) {
      strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
    }
    strip.show();
    delay(wait);
  }
}

uint32_t Wheel(byte WheelPos) {
  WheelPos = 255 - WheelPos;
  if(WheelPos < 85) {
    return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
  }
  if(WheelPos < 170) {
    WheelPos -= 85;
    return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
  }
  WheelPos -= 170;
  return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}
Leave a Reply