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.

For the turning on it's easy. If the anode stays high all the time (=connected to v+) then each of the three cathode also has to be set HIGH to be off. Just LOW one of the pins to turn the LED connected to that cathode ON.

 The resistor ratings are correct, use 1/2 W to be 100% sure they are safe. 

Thanks for the DUH moment. Keep them high and it won't turn on ;) DUH <smacks forehead>
When you make the "output" pin high, the current can no longer sink ito the picaxe. LED will go dark. The pin is still considered an output. An output for information, not current.
What if you were charlieplexing and needed an high, low and neither?

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 .

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).
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?