Build an RGB Matrix using some WS2812 modules

OVERVIEW

When you want to connect a lot of LEDs to a microcontroller like an Arduino UNO, using WS2812 is a great way to go.

The WS2812 and the WS2812B consist of a 5050 LED and a WS2811 IC into one small package.

The integrated WS2811 IC makes it possible to control each LED individually using only 1 pin.

The WS2812 and the newer WS2812B package version are essentially then same except that the B version uses 4 pins instead of the WS2812 6 pins to connect to a PCB and has bigger traces to be able to handle higher currents to run safely on a PCB.

For the purpose of this tutorial, we are using the RGB sticks which have 8 WS2812 LEDs on them, but you could use any WS2812(B) modules you want.

We will use the great FastLED library, which was written specifically to control these modules and is optimized for speed using a regular Arduino UNO.

SCHEMATIC

The great thing about these WS2812(B) modules is that we only need one digital pin on the UNO to control all of them.

Pin 2 is connected to the DIN (Digital In) of the first module.

VCC and GND are connected to the breadboard.

The DOUT, GND and VCC of the modules are connected to DIN, GND and VCC of the next module.

The output leg of the Potentiometer (10K) is connected to A1 (analog pin 1).

The VCC and GND of the UNO are connected to the breadboard.

*note: A good practice in general for WS2812 based products to prevent damage is adding a capacitor of 10μF or higher between the ground and VCC and a resistor of 100Ω to 1KΩ between the microcontroller and the signal pin is recommended.

If your are using an external power supply to power the LEDs you should use a capacitor and a resistor.

In this tutorial we are driving the LEDs directly from the UNO because the power requirement is not very high, so we decided not to use those, but if you want to be extra careful you can connect those if you want.

THE CODE

In this tutorial we will do two things:

First we will use the Potentiometer to light up the LEDs one by one, and change the color has more of them are being lit.

Next we will read the color value of each LEDs from arrays and make a simple animation.

This report would have more information with
“Show verbose output during compilation”
enabled in File > Preferences.

Brainy-Bits- Feb 01, 2017

Maurice:
There was an error in the code on the tutorial page.

I have refreshed the code on this page, so go ahead and copy paste the code again it should work now!

Thanks

Melissa- Feb 01, 2017

Hi thanks for your tutorial=) I found your post and it is nearly what I am looking for. :D:D

My question, can I put in 3 potentiometer knobs that each have their own animation. Animation ON animation OFF. So I dont have to scroll through 1-3 animations to get to what I want? And if having potetiometer knobs will “confuse” the code if they are turned all on at the same time by mistake, maybe another knob would be better and just a fade in fade out on the animation? Trying to get around this problem in my head but I’m so new to it all that it is very confusing understanding to code and wire such a thing. Hope you have a tiny tip for me on my way :)
Melissa