12th August 2015 | By: pambospalas
Driving an RGB LED
The use of RGB Light Emitting Diodes (LEDs) is very widespread. From the pixels that we see on advertising boards to indoor lighting that changes hue, they are being used more and more due to their power efficiency, long lifetime, small package and ease of use. This post describes briefly how they work and the principles behind controlling them.
Typically, although we might think of an RGB LED as a single diode, it consists of three separate diodes packaged together in a way that the emitted light is diffused together. Each diode emits light of a different wavelength, which as the name suggests, corresponds to the Red, Green and Blue colors of visible light (around 630, 500, 450 nm respectively).
Figure 1 – Visible light section of the Electromagnetic Spectrum
In order to drive the LED to produce an arbitrary color, the intensity of each color need to be modulated accordingly – for example, turning on fully the red and blue diodes and disabling the green one will produce purple etc. As with any LEDs it is good practice to have a constant current source, and simply modulate the signal using PWM. What this means is that the signal passing through the LED is kept on for a certain amount of time and off for a certain amount of time, in a cycle that repeats itself very quickly. The percentage of on/off time, otherwise known as the duty cycle, will determine the average power that the LED consumes and hence the brightness. By having 3 channels, one for each light, we are able to have complete control of the color emitted by modulating each one separately.
Most microcontrollers offer out of the box PWM on certain pins, and with some additional circuitry this could be used to drive one or more RGB LEDs. However, to save a lot of work, there are many ICs on the market which are dedicated RGB LED drivers for all kinds of applications. Using a device such as this can simplify design as you can just command it through I2C and it will handle everything for you. Many of these ICs also have other useful functions such as dimming and brightness control.
I hope that this shed some light (pun totally intended) into how an RGB light works and can be controlled!