LEDs are used often enough in home projects that it's worth a short tutorial on determining the proper resistor to be used with one.
The breakdown voltage of an LED (Vb) varies with color. This chart shows ranges of that voltage...
A typical supply current is I=20 ma. The required resistor can then be calculated from Ohm's law (R = V/I)
R = (Vs - Vb)/0.02
here Vs is the power supply voltage.
An example will help. Suppose we have a red LED we wish to power with a 12 volt battery. From the figure, the average Vb for a red LED is 1.9 volts.
R = (12-1.9) / 0.02 = 10.1 * 50 = 505 ohms
The standard series of resistors looks like..
1 1.2 1.5 1.8 2.2 2.7 3.3 3.9 4.7 5.6 6.8 8.2 10
All of these values can be multiplied by powers of ten (1.2 12 120 - 1200, etc.).
So the closest we can come to 505 is a 470 ohm resistor.
The resistor color code is
The third color band indicates the power of ten multiplier.
so a 470 ohm resistor will have yellow-violet-brown bands.
Most LEDs will have a flat area on the base to indicate the cathode (negative) terminal. Sometimes, the cathode lead is made shorter to indicate which it is.