LEDs (and, to be honest, most other diodes) exhibit a peculiarity called "negative temperature coefficient of resistance." In English? An ordinary conductor (like a piece of wire) shows an increasing resistance to current as its temperature increases. Pass a current through it, and the temperature increases, the resistance increases, the current
decreases, and the conductor stops getting hotter.
Pass a current through a diode junction, and the junction heats up, the resistance
decreases, the current
increases, the
temperature increases, the resistance decreases, the current increases, the temperature increases, and then the diode releases its magic smoke and the current drops to zero, never to rise again.
Put a resistor in series with the diode, and the current through the diode will be exactly equal to the current through the resistor, and that current will
never be greater than
I = V / R
where V is the voltage across the diode-resistor pair. That's why that resistor is sometimes referred to as a "current-limiting" resistor.
The data sheet for a LED will have two numbers of particular interest to us: the forward voltage V
F, and the maximum averge forward current I
Fmax. I
Fmax is the maximum continuous current the diode can carry without risk of damage, and is typically around 20mA. V
F is the maximum voltage that will appear across the leads of the LED (until you roach it), and is typically in the range of 1 to 3 volts. Even if the diode is connected by itself, directly to the voltage supply, the voltage across the leads (and the voltage across the supply's terminals) will not exceed V
F. Connect a diode with V
F = 2V to a 12V battery, and the voltage across the battery's terminals will drop to 2 volts. (Just for a moment; then you get smoke, and then the voltage jumps back to 12 volts.)
To choose a resistor, you need to know V
in (the voltage that will be powering the circuit,) V
F, and I
Fmax (in Amperes; if it's given in milliAmperes,
divide by 1000.) Then plug everything into the formula
R = (Vin – VF) / IFmax
to get the required resistance in Ohms. Add 5% or so, just to be safe, then buy the smallest resistor
larger than your calculated value.
If V
in happens to be a large value, you'll also need to watch the power rating on the resistor. Make sure that the power (Watts) rating on the resistor is larger than V
in*I
Fmax; otherwise you risk having the
resistor release its magic smoke and stop working. Most of the time, though, a typical quarter-Watt resistor should suffice.
I do hope that was at least moderately understandable, and that someone finds it to be of use.
Regards,
Prof. Darwin Prætorius von Corax, Executive Director & Lead Researcher
The Leverkusen Institute of Paleocybernetics
EDIT 4 Feb 2009: reformatted formulæ for readability