Getting Started With NeoPixel / WS2812 RGB LED
by opengreenenergy in Circuits > Arduino
131061 Views, 308 Favorites, 0 Comments
Getting Started With NeoPixel / WS2812 RGB LED
In this Instructable, we will explore about the addressable RGB LED (WS2812 ) or popularly known as Adafruit NeoPixel. NeoPixel is a family of rings, strips, boards & sticks of pulsing, colourful miniature LEDs. These are chainable from one to the next so you can power and program a long line of NeoPixels together to form an endless string of LEDs. You can use these LED strips to add complex lighting effects to any of your project.
You can find all of my projects on : https://www.opengreenenergy.com/
They comes with tiny 5050 ( 5mm x 5mm ) surface-mount package which includes three bright LEDs (Red, Green, and Blue) and a integrated driver chip (WS2811). It requires only one data input to control the state, brightness, and colour of all the three LEDs. By connecting the data output pin to the data input pin of the next strips, it is possible to daisy chain the LEDs to theoretically arbitrary length.
With combinations of RGB values ( 0 - 255 ) you can reproduce just about any colour, so in a sense a controllable RGB LED is a universal LED.
Parts and Tools Used
Type of RGB LED Strip
There are 2 major types of RGB LED strip : Analog strip and Digital Strip
1. Analog strip :
All the LEDs in the strips are connected in parallel, so it acts like single huge tri-color LED.You can sets a particular colour to the entire strips / strings.They are very easy to use and inexpensive but the limitation in this type of LED strips is that you can't control the individual LED's colours.
On each of these strips you’ll see (from left to right) first the LED , followed by an SMD resistor.
2. Digital strip :
A digital strip is that you address each LED individually and work in a different way. They have a chip for each LED, to use the strip you have to send digitally coded data to the chips. Because of the extra complexity of the chip, they are more expensive.
Notice the arrows indicating Data direction.If you connect the strip in reverse direction it will not work.
Types of Addressable RGB LED Strip
Addressable LED come with different model numbers like WS2801, WS2811, WS2812 or WS2812B. If you are new to this type of LED, you may confused among them.So lets identify them first . Basically WS2801 and WS2811 are the name of the IC which can control maximum 3 LEDs. However WS2812 is an improved version in which a WS2811 IC is integrated directly into a 5050 RGB LED package. The most recent model is WS2812B.
In this tutorial we will use the latest model WS2812B.
Image Source : Adafruit, Sparkfun, Polou
WS2801 and WS2811 / WS2812 Pins
WS2801 model have 4 input pins ( Vcc,GND,Data,Clock ) whereas WS2811 and WS2812 model have only 3 pins
( Vcc,GND and Data )
PIN ---> WS2801
5V -> Power (+5V)
CI ->Clock signal Input
CO -> Clock signal Output
DI -> Data Input
DO -> Data Output
GND -> Ground
PIN --> WS2812
5V -> Power (+5V)
CI -> N/A
CO - >N/A
DI ->Data Input
DO ->Data Output
GND -> Ground
Power Supply
Before you start any LED strip project, the first thing you will need to think about is Power Supply.One of these RGB LED contains 3 LEDs ( Red,Blue and Green ). We know a single LED draw approximately 20mA current at its highest brightness.So a single WS2812 LED can draw 3 x 20mA = 60mA at maximum brightness - white.
Can I run directly by Arduino ?
The answer is simply NO. As the amount of current required for the entire strip will be way more than your Arduino can handle.
You need a separate regulated power supply for it.The power supply must provide the correct voltage, and able to supply sufficient current. In most of the WS2812 strips, the operating voltage is 5 volts DC.
Example : For WS2812 8 x 8 matrix ( 64 LEDs ) you need 64 x 60mA = 3840 mA ( 3.84 A ) at all the LEDs set to its maximum brightness ( White Colour ). But its not advisable , keep the brightness lower to get maximum life.
I can recommend to set the brightness below 50 %. So you need 3.84 x 0.5 = 1.92A
So by taking some margin the recommended power supply is 5V / 2A .
Preparing the Power Supply
It is very easy to control WS2812B LED strip without extra circuitry and discrete components. If you have an Arduino , 5V power supply and few jumper wires then you can play with it.
Preparing The Power Supply :
I used a 5V/2A regulated power supply for running the NeoPixel LEDs.
We need two GND connection : one to the LED strip and other to the Arduino.
So I soldered two wires to the negative terminal and one wire to the positive terminal of the DC jack.
Arduino Connection :
The Arduino Connection is very easy.
LED Strip DIN -> Arduino D6
Power Supply GND -> Arduino GND
If you are using the external power supply to powering both the LED strip and Arduino, then you must connect the 5V supply to the Arduino 5V pin.
Good Practices as per Adafruit :
1. Adding a large capacitor (1000 µF, 6.3V or higher) across the + and – terminals. This prevents the initial onrush of current from damaging the pixels.
2. Adding a 300 to 500 Ohm resistor between your microcontroller's data pin and the data input on the first NeoPixel can help prevent voltage spikes that might otherwise damage your first pixel. Please add one between your micro and NeoPixels.
3. When connecting NeoPixels to any live power source or microcontroller, ALWAYS CONNECT GROUND (–) BEFORE ANYTHING ELSE. Conversely, disconnect ground last when separating.
Driving a 8x8 Neo Matrix
The LED matrix contains 64 RGB LEDs which use the WS8211 driver. Each pixel is individually addressable and you will require only one Arduino pin to control all the LEDs.
In the back side of the matrix there are two ports : Input ( 3pins ) and Output ( 3pins ).
The input port is connected to the Arduino and 5V external Power supply.The connection is follows
Matrix --> Arduino
DIN --> D6
GND --> GND
Matrix --> Power Supply
5V---> 5V
GND-->GND
Note : You shouldn't forget to connect the GND of both the power supply and Arduino.
Now power up the circuit and upload the code to watch few animations. I have set the brightness of the LEDs to about 30%.
Arduino Code :
The code and libraries are attached in the zip file.Download it.You can watch the video to know how to use the Software.
Downloads
Driving a Flexible 8X32 WS2812 RGB MATRIX
The 8x32 Flexible matrix is pretty cool.I ordered it from Sparkfun. You can create animations, games, or even incorporate them into a fun e-textiles project. On top of all that, thanks to its flexible backing, this LED Matrix can be bent and bowed to fit onto almost any curvy surface.
The connection with arduino is similar to the other NeoPixel LED matrix / Strip.
The Matrix come with terminal wires, so no need to solder.
Yellow : GND
Red : +5V
Green : Data
If you enjoyed this article, don’t forget to pass it along!
Follow me for more DIY projects and ideas. Thank you !!!