RGB LED strips
The price of LEDs has fallen by 90% since 2010 and it is expect to fall further in the coming years. This has made LED technologies more accessible to consumers. For instance, installing LED strips in your kitchen used to be a premium but these days, LED strips originating from China can be bought for a couples of ££s on eBay. You can either buy single colored LEDs or you can also purchase RGB LED strips. A RGB LED consist of 3 colored die (Red, Green and Blue) packaged together and by varying the voltage to each die, you can create the full color spectrum and not just Red, Green or Blue. An RGB LED strip Tutorial is presented in this post.

For this post, we bought 1 meter worth of the RGB LED strip on eBay for £2.79. A meter of strip contains 60 RGB LEDs in total and we purchased a weather-proof one.

RGB LED Strip Schematic

The RGB LED strip consists of sections connected in parallel and each section consists of 3 RGB LEDs (total of 9 LED dies) connected in series.
RGB LED strip schematic

Every 3-LEDS can be cut without damaging the rest of the strips. Each 3-LEDs section draws approximately 60 mA at 12V. So the full 1 meter strip consisting of 60 LEDs will draw 1.2 Amps if all the LEDs are powered at the same time. By using PWM-fading to change the colors, the power required will be reduced but a decent power supply is still needed.
RGB LED strips

Driving the RGB LED strip

The LED strip can easily be controlled with a microcontroller. By using PWM to drive the LEDs, the color of the strip can be varied. Since the LEDs may require an Amp or more to sink to ground, they cannot be driven directly from the microcontroller pin and should be powered using power transistors.

The connections for driving the LEDs from a microcontroller is at follows, with the I/O pin connected the microcontroller GPIO:
Microcontroller BJT Driver

Microcontroller code

If you decide to use an Arduino, then the PWM library can be used to drive the base of the power transistor.
Using the analogWrite(pin, value) syntax, you can specify a value of between 0 and 255; with 0 representing always off and 255 always on. For more information refer to Arduino PWM.

By varying the PWM value for the red, blue and green pin, you can run through the RGB colour spectrum. To better understand what values to put in the PWM value, open up any image processing software or simply paint in windows and go to the colour editor.
RGB colour spectrum
Set your Hue to 0 and Red to 255, you will notice that your cursor moves to the top. Now, if you drag your cursor from left to right (horizontally), the red value will decrease and the Green and Blue values will change. Check out the following animation:

So by writing an arduino code that changes the red, green and blue PWM values just like in paint, you can vary the colour of the RGB LEDs.
This can be translated into Arduino C code:

int red = 255;
for (int green=0; green <= 255; green++) { analogWrite(GreenPWMpin, green); delay(10); } for (int red=255; red >= 0; red--)
      analogWrite(RedPWMpin, red);
for (int blue=0; blue <= 255; blue++) { analogWrite(BluePWMpin, blue); delay(10); } for (int green=255; green >= 0; green--)
      analogWrite(GreenPWMpin, green);
for (int red=0; red <= 255; red++) { analogWrite(RedPWMpin, red); delay(10); } for (int blue=255; blue >= 0; blue--)
      analogWrite(BluePWMpin, blue);

The full code for this tutorial can be downloaded here: RGB LED STRIP Tutorial code


For this post, we used an Arduino Nano. The Nano has 6 pins capable of performing PWM; Pin 3, 5, 6, 9, 10, and 11.

The Arduino was connected to the driving transistors as follows:
G I/O -> Arduino Pin 3
B I/O -> Arduino Pin 5
R I/O -> Arduino Pin 6

And of course link all the grounds together.

Power everything and you will see light 🙂
We actually used a 6V power supply for the LEDs, hence they don’t seems very bright. Apologies for the shaky video.

Add a Comment

Your email address will not be published. Required fields are marked *