Saturday, March 12, 2016

RGB LED tutorial


This tutorial assumes that you know the basic principles behind normal LEDs.

What are RGB LEDs?

RGB LEDs are three LEDs combined into one. See below.

Image from: https://cdn.solarbotics.com/products/photos/84728eb26b0947ef6547884cea645502/LED-RGB-8CD5kCA-IMG_0965.jpg
Instead of 2 wires coming out, you now have 4 wires coming out. The longest one can represent ground or voltage, and the 3 others correspond to red, green, and blue. They also come in 2 variations: Common Anode and Common Cathode.

Image from: http://eeenthusiast.com/wp-content/uploads/2015/03/rgb.jpg


Whats the difference between Common Anode and Common Cathode? 

Common Anode will only work if you put a voltage(red wire) through the longest wire first and a Common Cathode will only work if you put a voltage(red wire) through the color wire(s) first. See the example below.

Image from: http://bildr.org/blog/wp-content/uploads/2011/01/RGBLEDs2.png
(Please don't use the above resistor values. Your LEDs most likely has different specifications)

So complicated! Why would I ever use them?

1) Space

With RGB LEDs, you conserve physical space compared to ordinary ones because RGB LEDs are after all 3 LEDs in one. Great for applications(props) that need different colors in a small space.

2) Color mixing and customization

Sure you can get all the colors in normal LEDs but you won't be able to get the full range of color. As in you can buy a pink LED and purple LED but you won't be able to buy an LED that is between those values if you want a pinkish-purple or purplish-pink color. In addition, true cyan LEDs are notoriously hard to get, companies like to label greenish-blue LED's as cyan. The only color RGB LEDs can't get is ultraviolet, but the control available to get all the other colors more than makes up for it.

So how do you use them?

You use them like any other LED. For the sake of simplicity, we will use a Common Anode RGB LED. Connect your power source to the longest lead on the LED, connect your resistor to the other LED lead you want to light up, and connect the other end of the resistor to the color that you want.

For example, if you want to get red light out of an RGB LED, you would connect it like this. assuming that your RGB LED is Common Anode.



Okay, but what about say yellow? You then have to connect the red line and the green line.



Other pins can be connected in a similar fashion. Here is a table for all of the possible combinations and colors.




Red
Green
Blue
Red
On
Off
Off
Green
Off
On
Off
Blue
Off
Off
On
Yellow
On
On
Off
Purple
On
Off
On
Cyan
Off
On
On
White
On
On
On


So if you want to get purple, you have to power the red and blue lines to get purple.
See that the colors match the RGB color wheel.

Image from: http://www.juude.info/color/colorImages/rgb.png


Which resistor do I use?

Calculating the resistor is no different than calculating resistors for normal LEDs. For just red, just green, and just blue, you calculate it like so. Vss is the supply voltage that you choose(your battery). Vf is the forward voltage of your LED (find the number in your LED specification sheet), If is the forward current of your LED(find the number in your LED specification sheet).

For Red, you use the Red Vf and If values from spreadsheet to calculate the resistor.



R=(Vss-(Vf))/If, where Vf and If correspond to red or blue or green Vf and If values.

For yellow,purple, cyan, and white you calculate the resistors as if you have parallel LEDs with an individual resistor for each LED.

For Yellow, you use the Red If and Vf values for the Red line and the Green If and Vf values for the Green line. You will run the formula two times. One with Red, one with Green.

R=(Vss-Vf)/If, where you run this formula for each branch present. Each branch has it's own Vf and If (corresponding to red or blue or green Vf and If values)so read the specification sheet carefully.

These calculations are for a single RGB LED. The resistor value will be different for multiple LEDs.

How do I mix the colors more

You have to change the resistor values. Say to get a greener yellow, you can either reduce the green line resistor value or increase the red line resistor value. If you do this, don't exceed the RGB LED's recommended specs for each red,green, and blue line. For things like this, I would highly recommend getting a potentiometer. It is a device that you twist with a screwdriver or flathead to get different resistances. See this wikipedia article.

I want to switch between colors.

This requires a 7 position switch(minimum) and rectifier diodes. See Myrtenaster build writeup 3 for an example. The circuit there uses a current regulator. To do it with resistors, place a resistor on each color branch of the RGB LED.

I want to cycle through all the colors automatically.

They sell cycling RGB LEDs. You connect all the leads and calculate the resistors like in the white case.

I want to *insert special effect here that isn't cycling*

Most likely requires a microcontroller and coding which is not covered in this tutorial. There are tons of other tutorials for this online.


And there you have it. A simple overview on RGB LEDs. Feedback is highly appreciated.



No comments:

Post a Comment