An LED is a diode made from a semiconductor material which generates photons of light when current flows through the material. The more current through the LED, the more light the LED will emit, the brighter it will be. However there is an upper limit which is the amount of current sufficient to damage the LED.
An LED offers little resistance to the current flowing through it. Most of the little resistance it offers comes from the energy lost from the emitted light and the photon generation is so efficient that the resistance is pretty negligible. However as current increases, increasing the amount of light, the LED will at some point fail because the amount of current going through the LED causes material failures. With sufficiently large amounts of current, catastrophic material vaporization may result in what amounts to a small explosion within the LED exterior envelope. With the lower current levels found in 3.3v or 5v digital circuits the most likely result is the semiconductor material fails and stops conducting and the LED no longer glows.
How does circuit voltage affect the current draw of an LED? Since an LED is a type of diode, the Shockley diode equation describes the current a diode allows at various levels of voltage. The equation shows that the results of the Shockley function for a given range of voltage follows an exponential curve. This means that small changes in voltage can make large changes in current. So using an LED in a simple circuit whose voltage is higher than the LED's Forward Voltage risks having the LED draw surprisingly more current than its recommended levels resulting in LED failure.
See Wikipedia topic LED Circuit as well as Wikipedia topic Shockley diode equation.
So the idea is to engineer the LED circuit so as to limit the amount of current flowing through the LED. We want to balance out having enough current to cause the level of brightness desired without having so much that the LED material fails. The most common method of limiting current is to add a resistor to the circuit.
An LED should have a data sheet that describes the LED's electrical characteristics and tolerances. For example see this data sheet Model No.: YSL-R531R3D-D2.
The first characteristics we are interested in is (1) what is the maximum current that the LED can sustain before material failure is possible resulting in LED failure and (2) what is the recommended current range. These and other Maximum Ratings for a typical standard red LED (different LEDs will have different values) are in a table as duplicated below.
In the table from the data sheet for this standard red LED we see that the maximum current is 20mA with the recommended range being 16mA to 18mA. This recommended range is the current for the LED to be at its brightest while not risking material failure. We also see that the rated Power Dissipation is 105mW. We want to make sure that in our LED circuit design we stay within these recommended ranges.
Looking in the next table we find a Forward Voltage value for the LED of 2.2v. The Forward Voltage value is the voltage drop when current is flowing through the LED in the forward direction, from anode to cathode. See What is “forward” and “reverse” voltage when working with diodes?.
If we were to use this LED in a circuit with 2.2v and a current of 20mA then the LED will dissipate 44mW which is well within our power dissipation safety zone. If the current changes from 20mA to 100mA the dissipation will be 5 times greater or 220mW which is well above the rated 105mW Power Dissipation for the LED so we could expect the LED to fail. See What happens to my LED when I supply too much current?.
To reduce the current through the LED to the recommended levels, we will introduce a resistor into the circuit. What value resistor should we use?
We calculate a resistor value using Ohms Law, V = I x R
. However we will make an algebraic transformation because we want to solve for Resistance rather than Voltage so we instead use the formula R = V / I
.
The value for I, current in amperes, is fairly obvious, lets just use the recommended minimum of 16mA or .016A from the LED data sheet in the transformed formula. But what value should we use for volts, V?
We need to use the resistor's voltage drop which is the contribution the resistor makes to the total voltage drop of the entire circuit. So we will need to subtract the voltage drop contribution of the LED from the total circuit voltage to determine the voltage drop contribution needed from the resistor. The voltage drop of an LED is the forward voltage value, the voltage drop in a forward direction from anode to cathode, from the table above.
For a standard Raspberry Pi project using the 3.3v rail as a power source, the calculation would be (3.3v - 2.2v) / .016A = 69 ohms (rounding 68.75 up)
So why is a resistor value such as 200 ohms commonly used when the calculations indicate 69 ohms?
The easy answer is that a 200 ohm resistor is a common resistor included in many experiment kits. We want to use a common resistor if the light emitted by the LED will not noticeably decrease.
So if we change from a 69 ohm resistor to a 200 ohm resistor, what is the change in the current? Again we use Ohm's law this time to solve for current in the circuit, I = V / R
or 3.3v / 200 ohms = .0165A
and when we look at the LED data sheet we see that this value is in the recommended range of 16 mA to 18 mA so the LED should be sufficiently bright.