Best RGB LEDs for any project (WS2812, aka NeoPixels)

Picture of Best RGB LEDs for any project (WS2812, aka NeoPixels)

When we're working with LEDs, we often like to control their state (on/off), brightness, and color. There are many, many different ways of going about this, but none are as compact a solution as the WS2812 RGB LED. In its tiny 5mm x 5mm package, the WS2812 includes 3 super bright LEDs (Red, Green, and Blue) and a compact driver circuit (WS2811) that only requires one data input to control the state, brightness, and color of the 3 LEDs.

At the expense of needing only one data line to control 3 LEDs, there comes a demand for highly precise timing in the communication with the WS2811. For this reason, a real-time microcontroller (e.g., AVR, Arduino, PIC) is required. Sadly, a Linux-based microcomputer or an interpreted microcontroller such as the Netduino or Basic Stamp cannot provide the sufficient timing accuracy that is needed. And so, in this Instructable I walk through the process of setting up, and controlling one of these LEDs with an Arduino Uno. Then, I show how easy it is to connect several of them together for an awesome lighting display!

Difficulty level: Beginner
Time to completion: 10-15 Minutes

Remove these adsRemove these ads by Signing Up

Step 1: List of Materials

Picture of List of Materials
This wonderful RGB LED comes in a 5050 (5mm x 5mm) package with 6 pads that are fairly easy to solder onto a breakout board.  As the only additional component needed is a de-coupling capacitor, the WS2812 honestly offers the best solution for controlling color and brightness of an RGB LED.  The embedded constant-current LED driver (WS2811) is remarkably useful for two reasons:
- A constant current of ~18mA will drive each LED even if the voltage varies.
- There is no need to add current-limiting resistors (a.k.a choke resistors) between the power supply and the LEDs.

All we need is a very simple design to provide Power, Ground, and 1 Control Input in order to create an awesome lighting display consisting of not one, but a whole array of RGB LEDs.  That's right!  By connecting the Data Out pin of one of these LEDs, to the Data In pin of another, we can drive them both independently with the same Control Input!  If it's not obvious how to do this, do not be troubled, by the end of this Instructable you'll be well on your way to adding WS2812 to any project you want!

For this Instructable here's a what we'll be using:

3 x WS2812 RGB LEDs (pre-soldered onto a tiny breakout board)
1 x Solderless Breadboard
Solid Core Wire (assorted colors; 28 AWG)
1 x Arduino Uno R3
1 x Break-away Pin Connector, 0.1" Pitch, 8-Pin Male (Right-Angle)
1 x Pin Connector, 0.1" Pitch, 8-Pin Female (Right-Angle)
1 x Breakaway Pin Connector, 0.1" Pitch, 8-Pin Male

USB A/B Cable
Wire Stripper
Soldering Iron

Depending on your project, the WS2812 RGB LEDs are also available without a breakout board for about $0.40 each, but the convenience of the pre-soldered option is attractive for simple applications.
querry431 year ago
Adafruit has has instructions for using these LEDs on a Netduino, although it involves replacing the firmware:

BTW, you can get them for much cheeper if you buy them in strips which can be cut to size. It also simplifies the wiring for some uses.  These are about 50 cents per pixel (same LED but the site calls them NeoPixels):

Great instructible!
acrobotic (author)  querry431 year ago
Thanks for the compliment! I completely agree that the strips are a much cheaper option (we also have them in stock now (:-):

However, sometimes people want a thick PCB rather than the flexible one used in the strips. This is especially useful if you're using a breadboard. Either way, we want you to have as many options as possible, so thanks for pointing it out, and for checking out the Instructable!
link ded
ronix_de10 months ago

In your modified code, you might want to change line 33 of the ino file (for-loop) to allow for more than three LEDs, easy since you defined them above :-)

acrobotic (author)  ronix_de9 months ago

Thanks for the bug report! I also fixed the color separation so that we get an even spread across the range (val = (val + 255/NUM_PIXELS) % 255;). Cheers!

dwisner1 year ago

I downloaded the fade, from step 6 (Which is great by the way!) but have the LED strip from you guys, (60) and I'm wondering if the code can be altered to run the fade across all 60 LEDS?

acrobotic (author)  dwisner9 months ago

Thanks! Sorry for the late reply. I've made changes to the code (as pointed out by @ronix_de) so that you can do as many LEDs as you want. I also corrected a bug in the color-step spacing so that you always get an even distribution of colors across all LEDs.

KDS44441 year ago
The link to your Ardunio Uno is dead... :(
acrobotic (author)  KDS44441 year ago
Hi, there! Thanks so much for letting us know. We've recently upgraded the site so some URLs moved around a bit. It is all fixed now, thanks again!