Basic LED Question

I just got my Arduino and have get it happily blinking out morse code all over the show.

I also bought a combined RGB LED with common Anode (which initially worried me, but I've discovered how to sink to make it work.. in theory).

It would fit so nicely with its cathode leads plugged into the PWM pins at 6,5 and 3 with the common anode in pin 4 and I could make all sorts of lovely colours (in theory).

The reason I say in theory is I'm not going to risk plugging in straight in without serial resistor(s) as I get the impression something would melt, either my LED or Arduino or both...

SO I have a few (n00b) questions:

  1. Why do I need a serial resistor? Why is the voltage too high for LEDS? or is it something else?
  2. Where can I put the resistor(s)? can one just go on the common anode or should each cathode have a resistor?
  3. People seem to be picking quite random values for their resistors from all the different things I've read. I have the specs for my RGB LED and the Arduino is there a sensible way to calculate what I actually need to use?

I'm a programmer and played around with electronics when I was little but always following specific instructions, I've just realised how little I know for working things out for my self. Its all part of the fun :)

Cheers, Nick

Read this. And google more, if necessary.

If it is a common anode, you need a resistor in each cathode. The values are calculated, not randomic. The link has the formula.

Can't believe I wikipedia'd LED and all sorts of other things and didn't find that.

Thanks heaps.

The resistors are there to limit current so you don't damage your Arduino pins or the LEDs. LEDs by themselves basically look like a short circuit and would conduct many amps if your power source across them were capable of delivering it. This in turn would then destroy your LED. The specs for your LED will tell you things like recommended current and maximum current, so you should choose your limiting resistor based on the current you want (higher current means brighter LEDs but shorter lifetime). Each parallel LED requires its own resistor, otherwise all of the current will go through the one that conducts at the lowest voltage. This can result in seeing only one of the LEDs lit, or in uneven brightness across the parallel LEDs. It will also shorten the lifetime of the one that's carrying the higher current.

  • Ben