Sub topic 7
Why the LED needs a resistor, and how to size it
This chapter assumes you know the basic meanings of voltage, current, and resistance, and that you can identify the Arduino pin and ground connections in a circuit. You will use Ohm’s law to choose a resistor for an external LED.
An LED, or light-emitting diode, is a diode that produces light when current flows through it in the forward direction. Its current does not increase gradually as voltage increases. Once the applied voltage reaches the LED’s forward-voltage range, a small voltage increase can cause a large current increase.
An Arduino output pin behaves approximately like a voltage source. If you connect an LED directly between the pin and ground, the LED cannot reliably limit its own current. Excess current can damage the LED, the pin’s output driver, or both.
A resistor in series limits the current. “In series” means that the same current must pass through the resistor and the LED.
The resistor calculation
Use the voltage that remains after the LED’s forward voltage has been subtracted from the supply:
\[ R = \frac{V{SUPPLY} - VF}{I_{LED}} \]
Where:
Ris the resistance in ohms.VSUPPLYis the output voltage from the Arduino pin.VFis the LED’s forward voltage.ILEDis the desired LED current in amperes.
For a red LED on a 5 V Arduino board, use these example values:
VSUPPLY = 5 VVF = 2 VILED = 0.010 A, or 10 mA
The calculation is:
\[ R = \frac{5 - 2}{0.010} = 300\ \Omega \]
A resistor does not need to match the calculated value exactly. Choose the next commonly available value that limits the current to at most the target. A 330 Ω resistor is a suitable choice:
\[ I = \frac{5 - 2}{330} \approx 0.0091\text{ A} \]
That is about 9.1 mA. The LED will usually be bright enough, and the lower current gives more safety margin than a resistor smaller than 300 Ω.
| Board output | Typical LED forward voltage | Target current | Calculated resistance | Practical choice |
|---|---|---|---|---|
| 5 V | 2.0 V, red LED | 10 mA | 300 Ω | 330 Ω |
| 5 V | 3.0 V, blue LED | 10 mA | 200 Ω | 220 Ω |
| 3.3 V | 2.0 V, red LED | 5 mA | 260 Ω | 330 Ω |
The forward voltage varies with LED color, part, temperature, and current. Use the value from the LED’s datasheet when accuracy matters. For a beginner circuit, a conservative estimate and a standard resistor value are usually sufficient.
Check the resistor’s power rating
The resistor also dissipates power as heat:
\[ P = I^2R \]
With 9.1 mA through a 330 Ω resistor:
\[ P = (0.0091)^2 \times 330 \approx 0.027\text{ W} \]
A common 0.25 W resistor is comfortably above this value. For ordinary indicator LEDs connected to an Arduino pin, resistor power is rarely the limiting factor. The output pin’s current limit still matters. Keep the LED current modest, and check the board’s documentation rather than assuming every board has the same limits.
Polarity and wiring
The resistor is not polarized, so it can face either direction. The LED is polarized:
- The anode is the positive side and connects toward the Arduino output through the resistor.
- The cathode is the negative side and connects toward ground.
- The longer leg is often the anode.
- The flat edge on many LED packages marks the cathode.
Physical markings are useful but not universal. If the LED has a datasheet, use its pin diagram. A reversed LED normally does not light, but reversing it does not replace the need for a resistor.
When the Arduino pin is HIGH, current flows from the pin, through the resistor and LED, into ground. When the pin is LOW, there is little voltage across the series path, so the LED turns off.
Exercise
A red LED has a forward voltage of 2.0 V. It is connected to a 5 V Arduino pin, and the target current is 8 mA. What resistor value should you calculate, and which common value would you choose?
Show answer
Calculate R = (5 - 2) / 0.008 = 375 Ω. Choose a common value of 390 Ω or a larger value such as 470 Ω. The larger value reduces the current and brightness.