Exploiting this lack of knowledge, people on the Internet sell 5-volt, 9-volt and 12-volt “LED resistors”. This may sound handy to those who don’t want to dig deeper but is a waste of money when you know that there ain’t no such thing as a 12-volt LED resistor.

Calculate the "LED resistor"
The resistor in question is a current limiting resistor and it prevents damaging the LED by excessive current. Its value depends on the supply voltage and the desired current through the LED. You can easily calculate the resistor value yourself:- Choose the LED’s supply voltage, call it Vsupply.
- Choose the intensity of the current you want to push through the LED, Iled. The more current through an LED, the brighter it will shine. For common 3-mm and 5-mm LEDs 10 mA is a popular value.
- Figure out the forward voltage (Vforward) of the LED for the current you chose. This voltage increases slightly with the intensity of the current and the wavelength of the emitted light (color of the LED). For a red LED it is often given as around 1.8 volts, but it depends on the LED. When dealing with red, orange, yellow and green LEDs, you can start by assuming a forward voltage of 2 V, blue and white LEDs have a value of around 3.2 V.
VRled [V] = Vsupply [V] – Vforward [V] = 9 – 2 = 7 V
Rled [Ω] = VRled [V] / Iled [A] = 7 / 0.015 = 466.7 Ω
(note that the units used are ohms, volts and ampères, not milliampères or something else). The nearest standard value is 470 Ω (±5%).
Checking this on a breadboard with a real, randomly chosen green LED from the junkbox and a resistor measured at 468 Ω, Vforward turned out to be 2.16 V (2.06 V for a red LED, and 2.04 V for a yellow one). Reversing the calculation, we find:
Iled [A] = (Vsupply [V] – Vforward [V])/Rled [Ω] = (9-2.16)/468 = 0.0146 A = 14.6 mA.
Pretty good, huh? If your LED current turns out to be too far from the desired value, adjust the resistor’s value. A smaller value increases the current, make it larger to decrease it.

Heat is the enemy of electronics
The current that flows through the LED also flows through the series resistor. Current flowing through a resistor heats it up. The resistor must be capable of dissipating the heat without cracking up. In other words, it must be rated for the power it has to handle. The power dissipated by the resistor is now given as:PR [W] = Iled [A] × VRled [V]
Thus, for our example, the resistance must be rated for:
0.015 × 7 = 0.105 W = 105 mW
This is fine for a standard 0.25 W through-hole carbon resistor, but too much for many thick-film SMD resistors. To solve this, you can place several identical resistors in parallel while multiplying their value by the number of resistors in parallel. For instance, one 470 Ω resistor can be replaced by two 940 Ω resistors in parallel. (In real life you would use two resistors of 1 kΩ.)