Let’s make an RGB Matrix using some WS2812 modules
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.
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.
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.
Don’t forget to check out our Tutorial video for more information.