What the resistor is for
An LED does not limit its own current. Wired straight to a pin, it takes whatever the pin can give. The 150 Ω resistor on the board sets the current to about 13 mA from a 5 V pin, which the pin can supply all day.
An LED does not limit itself
A light bulb has a filament that resists current. An LED has almost nothing: once the voltage across it passes a threshold, about 3 V for a blue one, the current rises very steeply for every extra fraction of a volt. Connect one straight across a 5 V pin and there is nothing to stop the current climbing.
So something else has to set the current, and on this board that is the 150 Ω resistor beside the LED. The part is marked 1500, which is the code for 150 Ω: 150, followed by no zeros.
The arithmetic
The pin's voltage is shared out along the loop. The LED takes about 3.0 V of it. The resistor gets whatever is left, and Ohm's law turns that into the current:
current = (pin voltage - LED voltage) / resistance
= (5.0 V - 3.0 V) / 150 Ω
= about 13 mA13 mA is comfortably inside what an Uno's pin may supply. The ATmega328P's absolute limit is 40 mA per pin, and an ESP32's default output drive is about 20 mA.
The 3.0 V is measured rather than taken from a datasheet: the LED on this board has none. On the bench, one board showed 2.0 V across the resistor with the pin at 5 V and 0.3 V at 3.3 V, and both fit an LED taking about 3.0 V. Treat every current in this book as approximate.
Without the resistor
Set the figure to None. The formula divides by zero, and in the real circuit that means the current is set by nothing on this board. The pin's own output transistor becomes the resistor, and it heats up trying to supply far more than it is rated for.
It does not always fail at once, which is why beginners get away with it for a while. The LED burns brighter, the pin runs past its limit every time it goes HIGH, and one day that pin stops working. This is why the resistor is already soldered to the board. It is the part that makes it safe to plug in without choosing a resistor yourself.
A bigger resistor is always safe
Any value that keeps the current under the pin's limit is correct. Going up only costs brightness: 330 Ω gives about 6 mA from 5 V, and 1 kΩ about 2 mA, which is dim but visible. Going down, the LED gets brighter, but the pin works harder and gets closer to its limit. The 150 Ω on this board is the value that is bright on a 5 V board and still lit on a 3.3 V one.
When it does not work
Don't. Without it the only limit on the current is your microcontroller's output pin, which will run well past its rating trying to supply it. It may work for a while, which is what makes it tempting. To make the LED brighter, use a 5 V board, not a smaller resistor.
No. A four-character code on a small resistor is three digits and a multiplier: 150 followed by zero noughts, so 150 Ω. A 1.5 kΩ resistor would be printed 1501. The value on this board is 150 Ω.
No. In a single loop the same current flows through every part, so the resistor limits it wherever it sits. On this board it is between the LED's cathode and GND, which is just where it fitted best.
A blue LED needs about 3 V before it conducts, more than a red one, so there is less voltage left over for the resistor. 150 Ω keeps about 13 mA from 5 V and still lets a 3.3 V board light the LED. With 220 Ω it would be dimmer everywhere.
Edit this page — content/books/xl-led/what-the-resistor-is-for.mdx
Questions about this product
See what other owners have asked, and read their solutions.
XL LED
Loading discussions…
Discuss this article
Ask about this page. The answer stays here, on the page it belongs to, for whoever hits the same wall next.