*lot*of questions regarding which resistor(s) they need for a project using LEDs. Here are two formulas to use to figure out just what you need.

First, you need to know the resistance needed. For this, you need Ohm's Law.

(Vs-Vf)/If=R

where:

Vs = Source Voltage (either 3.3v, 5v, or 12v)

Vf = Forward Voltage (almost always stated on the package)

If = Forward Current (usually 20-30mA, stated as 0.02 to 0.03 in the formula)

R = Resistance in Ohms

For example, a 2.1v, 20mA LED using a 5v power source would figure like this:

(5-2.1)/0.02=R

2.9/0.02=R

R=145 Ohms

Use this number as a rough guide and purchase the resistor(s) that is the next highest value of R (in this case, I believe it'd be 170 ohms).

You also need to know what Watt rated resistor you need.

P=If*(Vs-Vf) <--- Power Law

P = Power in Watts

If = Forward Current from the previous formula

Vs-Vf = what you used in the previous formula also

Continuing with the example:

P=0.02*2.9

P=0.058 watts

If P <= 0.25, then use 1/4 Watt rated

If P > 0.25 but <= 0.5 use 1/2 Watt rated

If P > 0.5 then use 1 Watt rated

Using these numbers will help you purchase the resistor(s) you will need for a project working with LEDs.

*UPDATE*

Here's an update to an old post (for what it's worth)...calculating for parallel and series-wired LEDs.

Parallel-wired LEDs maintain the same Vf, but the If increases for each LED in parallel (e.g., two 20mA LEDs in parallel would use .04 for If), making it more or less IfT=If1+If2+etc.

Series-wired LEDs maintain the same If, but the Vf increases for each LED in series (e.g., two 2.1VDC LEDs in series would use 4.2 for Vf), making it more like VfT=Vf1+Vf2+etc.

**Edited by EvilWays, 23 October 2004 - 11:03 PM.**