Resistors are the most common part in electronics, and the simplest. They resist the flow of current. That sounds like a nuisance, but it is exactly what you need to protect an LED, set a voltage, or pull a pin to a known state. This guide covers how they work and how to pick the right one.
What a resistor does
Think of current as water flowing through a pipe. Voltage is the pressure pushing it along, and a resistor is a narrow section of pipe. The narrower the section, the less water gets through for the same pressure.
Resistance is measured in ohms (Ω). A 1 kΩ resistor is 1,000 ohms, and 1 MΩ is a million.
Ohm's law: the one formula you need
Voltage, current and resistance are tied together by Ohm's law:
V = I × R
V is the voltage across the resistor in volts, I is the current through it in amps, and R is the resistance in ohms. Rearrange it to find whichever one you don't know:
I = V / Rgives the current.R = V / Igives the resistance you need.
So 5 V across a 1 kΩ resistor drives 5 / 1,000 = 0.005 A, which is 5 mA.
Worked example: a resistor for an LED
Once an LED reaches its forward voltage, a tiny rise in voltage causes a large rise in current, so on its own it can't limit its current. Without a resistor it would draw far too much and burn out. The resistor sets the current instead.
- Find the LED's forward voltage. A red LED drops about 2 V. Blue and white ones drop about 3 V. The datasheet gives the exact figure.
- Pick a current. Standard 5 mm LEDs are bright at 10 to 20 mA. We'll aim for 15 mA.
- Work out the voltage left for the resistor. 5 V supply minus 2 V for the LED leaves 3 V.
- Apply Ohm's law. R = 3 V / 0.015 A = 200 Ω.
- Round up to a value you can buy. The nearest common value above 200 Ω is 220 Ω, giving 3 / 220 = 13.6 mA. Rounding up keeps the current a little lower, which is the safe direction.
Here is the same calculation in Python, so you can try other LEDs and supplies:
def led_resistor(supply_v, led_v, current_ma):
"""Return the exact resistor value in ohms for an LED."""
return (supply_v - led_v) / (current_ma / 1000)
E12 = [10, 12, 15, 18, 22, 27, 33, 39, 47, 56, 68, 82]
def next_standard(ohms):
"""Round up to the next E12 value, the common resistor range."""
decade = 1
while True:
for base in E12:
if base * decade >= ohms:
return base * decade
decade *= 10
exact = led_resistor(5, 2, 15)
r = next_standard(exact)
current = (5 - 2) / r * 1000
print(f"Exact: {exact:.0f} ohms, use {r} ohms, current {current:.1f} mA")
# Exact: 200 ohms, use 220 ohms, current 13.6 mA
Not sure which resistor in your drawer is 220 Ω? Check the bands with the resistor colour code calculator.
Power: will the resistor get hot?
A resistor turns the voltage it drops into heat. The power it has to handle is:
P = V × I or P = I² × R
In the LED example, 3 V × 0.0136 A = 0.041 W. Ordinary through-hole resistors are rated at 0.25 W, so that is fine. As a rule of thumb, choose a resistor rated for at least twice the power it will actually see, so it runs cool and lasts.
Series and parallel
When you can't find the exact value you need, combine resistors.
- In series (end to end), the values add up. 100 Ω + 220 Ω = 320 Ω.
- In parallel (side by side), the total is lower than the smallest one:
1 / R = 1 / R1 + 1 / R2. Two equal resistors in parallel give half the value, so two 1 kΩ resistors make 500 Ω.
Two resistors in series are also how you build a voltage divider, one of the most useful circuits there is.
Types of resistor
- Carbon film: cheap and fine for most hobby work, usually ±5%.
- Metal film: more accurate (often ±1%) and less noisy. They usually have five colour bands, often on a blue body.
- Surface mount (SMD): tiny parts soldered onto the board surface, used in almost all modern products.
- Variable resistors and potentiometers: a knob or slider changes the resistance, for volume controls and adjustments.
Reading SMD resistor codes
SMD resistors are too small for colour bands, so they carry a printed number instead:
- Three digits: two digits then a multiplier.
103is 10 followed by 3 zeros, which is 10,000 Ω (10 kΩ).221is 220 Ω. - Four digits: three digits then a multiplier, used for 1% parts.
4702is 47,000 Ω (47 kΩ). - An R marks the decimal point.
4R7is 4.7 Ω.
Some very small 1% parts use a different two-digit-and-letter code, called EIA-96. If the marking looks like 01C, look it up in an EIA-96 table.
Quick recap
- Resistors limit current. Ohm's law, V = I × R, links voltage, current and resistance.
- For an LED, subtract the LED's voltage from the supply and divide by the current you want.
- Round up to a standard value and check the power rating.
- Series values add. Parallel values combine to something smaller.
Going deeper
Tolerance and the E-series
Standard resistor values come from the IEC 60062 "E-series". E12 has 12 values per decade and suits ±10% parts. E24 has 24 values and suits ±5%. E96 has 96 values and suits ±1%. The values are spaced so that each one's tolerance band roughly meets its neighbours'. That's why 4.7 kΩ exists but 5 kΩ doesn't in E12. With a ±5% 1 kΩ resistor, anything from 950 Ω to 1,050 Ω is in spec, so design circuits to work across the whole range.
Worst-case design
When accuracy matters, work out the extremes. This checks the output of a divider made from two ±1% resistors:
vin, r1, r2, tol = 12.0, 10_000, 4_700, 0.01
def vout(a, b):
return vin * b / (a + b)
nominal = vout(r1, r2)
low = vout(r1 * (1 + tol), r2 * (1 - tol)) # R1 high, R2 low
high = vout(r1 * (1 - tol), r2 * (1 + tol)) # R1 low, R2 high
print(f"{nominal:.3f} V, worst case {low:.3f} to {high:.3f} V")
3.837 V, worst case 3.785 to 3.889 V
Temperature coefficient
Resistance drifts with temperature, specified in parts per million per °C (ppm/°C). A 10 kΩ resistor rated at 100 ppm/°C changes by about 1 Ω for each °C, so a 30 °C rise shifts it by roughly 0.3%. Metal film resistors are commonly 50 to 100 ppm/°C. Precision thin film parts go down to a few ppm/°C, which matters in measurement circuits.
Power derating and voltage limits
A resistor's power rating applies up to a stated ambient temperature, often 70 °C, and falls above that, so check the derating curve in the datasheet. Many designers also use only half the rated power for reliability. Resistors also have a maximum working voltage, which matters for small surface-mount parts in high-voltage circuits even when the power is low.
Noise
Every resistor generates a little random "thermal" (Johnson–Nyquist) noise voltage: V = √(4kTRB), where k is Boltzmann's constant, T the temperature in kelvin, R the resistance and B the bandwidth. A 10 kΩ resistor at 300 K over a 20 kHz audio bandwidth produces about 1.8 µV RMS. It's tiny, but it sets a floor for sensitive amplifiers, which is why low-noise designs use lower resistor values where they can.
Choosing pull-up resistor values
A pull-up is a trade-off. A low value (say 1 kΩ) gives fast, noise-resistant edges but wastes current whenever the line is held low: 3.3 mA at 3.3 V. A high value (100 kΩ) saves power but makes slow edges that pick up noise. For buttons, 10 kΩ is a common middle ground. For I²C, the right value depends on bus speed and wiring capacitance, typically 2.2 kΩ to 10 kΩ.
Sources
The main references behind this guide. Numbers we worked out ourselves, such as the code outputs, come from running the code.
- IEC 60062: Marking codes for resistors and capacitors (paid standard, not online)