Don't ask me what prompted me to post this. Guess it's because the question often comes up here, what value of resistor do I need to run my LEDs off my 12-volt power supply?
So here's the generalized formula which should work for every situation. Just plug the numbers in and turn the crank.
Assuming you have a DC power supply, a single LED with a single resistor in series with it:
Vt - Vled R = ----------- Iled
where
Vt = total voltage (power supply voltage) Vled = operating voltage of LED Iled = operating current of LED (in amperes)
For example, with a 12-volt power supply and a 2-volt, 20mA LED, you'd get
R = (12 - 2) / 0.02 = 500 ohms.