Written by Eli on Monday, August 06, 2018.
This post was originally written on November 8, 2012.
Running an RGB LED on 12 Volts DC is just like running any other LED, except you need 3 current limiting resistors instead of 1.
Even though there are 4 leads on an RGB LED, It is still a "Simple" matter of using Ohm's law and some information from the LED's datasheet to calculate the correct value and size for the current limiting resistors. This may not seem so easy if you are new to electronics or have limited experience with LEDs but don't worry – the math required could be done by your 5th grade son or daughter.
For this example, I'll be using Vetco's VUPN6563 Ultra-Bright RGB LED (Common Cathode). – It comes in a package of 3 LEDs for a very affordable price. The steps below will work for Common Cathode or Common Anode LEDs.
An LED draws more current as the voltage being used to run it is increased.
Current causes the LED to heat up; high current results in too much heat. If you draw more current than the maximum listed "forward current” in the datasheet, the LED will self-destruct in a less than spectacular flash of light with more smoke than you care to inhale. A properly sized current limiting resistor will dissipate the extra current (in the form of heat), that would normally be flowing through the LED when running higher than the rated forward voltage.
It's a good practice to build in a safety margin when it comes to limiting current. Running an LED at its maximum specified forward current could result in a shorter life with reducing light output over time. Reducing the current to just below the maximum forward current gives the LED slightly less light output, but a much longer life.
There are 2 steps to selecting the correct resistor:
1) Calculate resistor value (in ohms)
2) Calculate Power dissipated by the Resistor (in watts)
To calculate the resistor value (in ohms) and size (in watts), we need to know the following:
The datasheet for the RGB Common Cathode LED shows that the forward voltage is 2.0 volts for the Red segment, 3.0 volts for the Green segment and 3.0 volts for the Blue segment. The forward current is listed as 20mA for all 3 segments.
Notice that 3 separate voltage values are listed. Does this mean that we need 3 separate resistors? Yes -- interesting things will happen if only one resistor is used on the cathode, for example, the Green and Blue will have slightly less light output and the Red will appear to be brighter than if we used 3 individual resistors. If you choose to use only 1 resistor, size it for the smallest voltage and current value, but be sure to increase the size of the resistor so that it can dissipate enough heat for all 3 elements (multiply the power dissipation by 3).
For this example, we are going to calculate the resistor value required for the red LED segment.
Here is the data we have now:
This is formula from Ohm's Law that we will use to calculate the resistor value:
Resistor Value (Ohms) = (Operating Voltage – LED Forward Voltage) / LED Forward Current
Resistor Value (Ohms) = (12 – 2.0) / 0.020
The resistor value we need is 500 Ohms. Since 500 ohm resistors aren't commonly available, we'll pick the next closest value: 560 Ohms. Always pick the larger of two close resistor values. This will help insure that the LED stays below the rated If (max forward current).
Now we need to find out what size resistor to use (1/8W, 1/4W, 1W, etc). This is also very simple math using Ohm's Law:
We know from step 1 that the voltage is 10 Volts (12 Volts – 2.0 Volts) and the resistance is 560 Ohms. Here's the math: 10^2 / 560 = 0.178
The resistor will be dissipating 0.178 Watts, or 178mW. A 1/4W (250mW) resistor will handle this safely. We should pick a 1/4W, 560 Ohm resistor, Vetco Part Number NTE-QW156 is a good choice.
Next we run the same calculations in steps 1 and 2 for the Green and the Blue segments (Vf=3.0, If=20mA). The resistor value for Green and Blue is: 470 Ohms. Vetco Part Number NTE-QW147 is a 470 Ohm, 1/4W resistor.
When complete, our RGB LED circuit looks like the diagram below. If you connect all 3 anodes to power at one time, the LED will produce a white light.
[Schematic Diagram of RGB LED + Resistors]
Resistors are a simple way to limit current, but they are not efficient. Excess power is wasted as heat. A better alternative to current limiting resistors is to use Pulse-Width-Modulation (PWM) to send specially timed and sized voltage pulses to the LED. PWM will allow you to control the brightness of the individual LED segments, creating a dazzling array of different color combinations. PWM control of RGB LEDs using an Arduino Microcontroller will be discussed in a future blog post.
PS: Don’t want to do this math on your own? Try this cool LED Resistor Calculator: http://ledcalc.com/