Getting Started With NeoPixel / WS2812 RGB LED

by opengreenenergy in Circuits > Arduino

130359 Views, 308 Favorites, 0 Comments

Getting Started With NeoPixel / WS2812 RGB LED

IMG_2456.jpg
IMG_2467.jpg
11821-01 (1).jpg
How To Run a 8x8 NeoPixel RGB Matrix ( WS2812 ) By Arduino
0.jpg

[ Play Video ]

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

5773dfe1deafa470f20004fb.jpeg

Parts :

1. 8 x 8 Neo Matrix ( Banggood )

2. Arduino Uno ( Amazon )

3. 5V /2A Power Supply ( Amazon )

4. DC Jack ( Amazon )

5. Jumper Wires ( Amazon )

6. 8 x 32 Flexible WS2812 Matrix ( Sparkfun )

Tools :

1. Soldering Iron ( Amazon )

2. Wire Cutter / Stripper (Amazon )

Type of RGB LED Strip

5773e0ad15be4d0d1d0001bd.jpeg
FIWC76VIPY0N9T3.MEDIUM.jpg

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

LED-WS2801-BK-32-3-800x533.jpg
577408884936d46ec30013a0.jpeg
0J5009.1200.jpg
51f02cd5ce395fdb0f000001.png

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

5773e3684936d4329e00071f.jpeg
5773e42d45bceb110c000c19.jpeg

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

5773e4a22e7fb615bf0002de.jpeg

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

6437_10_hands_on_look_at_adafruit_s_neopixel_rgb_led_strip.png
25flQ.jpg
IMG_2499.JPG
IMG_2501.JPG

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

577407af15be4d2b3f0008a5.jpeg
5773e4e445bceb110c000c20.jpeg
5773e553937ddb023a000085.jpeg
5773e5a72e7fb6894500075c.jpeg
5773e5d867400c10ed000051.jpeg

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

IMG_2502.JPG
57740706deafa470f2000585.jpeg

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 !!!