Let's Make Robots!

Tri-Color LED Resistor Question

I've seen Oddbots tutorial about LEDs and picking the right resistor, but since this LED costs a few bucks and the wordage is different on Radio Shacks parts I want to make sure I have it right.

Supply coltage is 5 volts
Forward Current 30mA (green/blue), 50mA(red)
Forward Supply 3.5 volts typical, 4 volts max (green/blue); 2 volts typical, 2.6 volts max (red)

I am thinking I need to use a 51 ohm resistor for green and blue and a  68 ohm for the red to get them as close to max as possible using resistors I already have on hand. Can someone verify this? I already blew one a few months ago when I was playing around and at almost $4 it is an expensive POOF! :)

Also since the LEDs all have a common anode I was going to hook up the resistors to the cathode for each LED and then to a PIN on a pixace 28x1. How would I turn on the LED on a specific pin doing it this way? I am assuming I would set th epin to LOW to run the LED on. What state would it have to stay in to turn the LED off? I know this is probably a RTFM moment so feel free to reply with RTFM "subject" and I will research it ;) I just wasn't sure WHAT to look up in the first place. This is for my DOGU bot I hope to have finished by the end of next week. A blog is to come in a few days once I make visible progress.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Its working but the numbers returned via readadc are all 220-255 unless I cover the LDR until it is completely dark then it is in the 120-130 range. I played with different resistors and go the same numbers. Any ideas on how I can make it less sensitive so I get a larger range?

What resistor values are you using? Depending on the LDR then the series resistor may need to be as low as 2K or as high as 2M. If possible get a 1M pot in series and adjust it.

Using your ADC in 10bit mode will also give you better definition.

Using a 10k beterrn the LDR and ground. By using readadc10 it seems to give better values. Now I need to make a chart in excel with values when nothin gis in front and when various colors are in front of it so I can figure out my color detecting algorithm. Thanks for the troubleshooting Oddbot.
Your values are good for maximum current through LED. However as the Picaxe can only sink 20mA per output (to be safe) you either have to increase the resistor values to 75ohms (G & B) and 150ohms (R) OR use a transistor to drive each of the R-G-B cathode legs of the LED. Section 3 of the Picaxe manual gives some interfacing ideas. And the resistors only have to be 1/4W, as even the Red LED will only draw 50mA, dropping 3 Volts across the resistor; a total of 0.15W (or approx. 1/6W).

The LEDs draws too much current for the PICAXE (LEDs green 30mA, red 50mA, PICAXE 25mA). You need other resistor values.

Here is a LED calculator tool (always useful)

For 5V, 25mA  I found those values:

Green, Blue LED 82Ohm

Red LED 120 Ohm

These are minimum values for the resistors for maximum current. I would start with a current of 15 or 20mA .

I would like to see your data sheet. My Tri-colour is a common cathode.
Datasheet? LOL its RadioShack they dont have diagrams or datasheets! Hooking it up to 5 volts with resistors pin 1 is ground for red, pin 2 is voltage for all colors, pin 3 is ground for green and pin 4 is ground for blue.

Ignoring the fact that the picaxe isn't rated for more than 25mA per pin. Some things you need to conside:

1. 30mA will be the maximum continuous value @ 25 degrees celcius. You may have to derate that for hot days

2. with all three elements on at once the power dissapation would be 285mA (Fwd voltage x current of each element added together). Can the LED handle this?

3. Are the elements on continously or intermittantly and when on, for how long?


They wont be on continuously. I am using them as part of a sensor to detect the color of an object. I have it breadboarded and will see how it works as is...

After we discussed it on Frits's Amanda LDR I have wanted to try it. I've also got one on Mr. Tidy. I ended up using your idea as my version needed three analog inputs and in this case I don't care about the colour of the ambiant light.

Mr. Tidy is not in the Mr. Basic contest as I am working for DAGU now.