What a resistor is actually for
A resistor restricts the flow of current. That sounds dull, but it is one of the most useful jobs in a circuit, because many components are happy only when current stays within a limit. Nearly every resistor in a hobby project is doing one of three things:
- Limiting current, for example in series with an LED.
- Dividing voltage, for example to scale a sensor signal into a range a pin can read.
- Giving a pin a default state, which is the role of pull-up resistors.
Knowing which job a resistor performs tells you how much its exact value matters.
The LED example
An LED does not behave like a resistor. Once it starts to conduct, its voltage stays roughly constant while its current can rise sharply with only a small increase in supply voltage. Without something to limit the current, an LED can be driven far too hard and fail, sometimes in an instant.
The usual approach is a series resistor sized from the voltage it must drop and the current you want. The relationship comes from Ohms law: resistance equals voltage divided by current.
Worked example, with illustrative figures that you should always check against your own LED’s datasheet:
- Supply: 5 V
- LED forward voltage: about 2 V (this varies with colour and part)
- Chosen current: 10 mA (0.010 A)
The resistor must drop the difference, 5 V minus 2 V, which is 3 V. Then 3 V divided by 0.010 A gives 300 ohms.
Resistors come in standard steps rather than every number, and 300 ohms is not one of the common values. Choosing the next standard value up, 330 ohms, gives 3 V divided by 330 ohms, which is about 9.1 mA. Slightly less current, slightly dimmer, and safely under the target.
The general lesson is to round up when in doubt about current-limiting. A slightly higher resistance means a slightly dimmer LED. A lower one means more current than you planned.
Power rating: the number people forget
A resistor turns the energy it drops into heat. Its power rating says how much heat it can shed without being damaged. Power is voltage across the resistor multiplied by the current through it.
In the LED example, 3 V times about 0.0091 A is roughly 0.027 W, or 27 mW. A common small resistor is often rated at a fraction of a watt, so there is a large margin. Check the actual rating of the parts you buy.
The trouble comes when a resistor carries more current or drops more voltage. Suppose a 100 ohm resistor sits across a 9 V supply. Current is 9 divided by 100, which is 0.09 A. Power is 9 times 0.09, which is 0.81 W. A small resistor rated well below that would overheat, discolour and possibly burn, which is both a fault and a hazard.
A common habit is to choose a power rating well above the calculated figure, leaving margin for warm enclosures and supply variation. Treat the rating as a limit, not a target.
Tolerance: how exact is the value?
Resistors are not made to exact values. Tolerance tells you how far the true value may stray, expressed as a percentage. A 1 kilohm resistor with 5% tolerance could be anywhere from 950 ohms to 1050 ohms. Tighter tolerances cost more and are generally available but are rarely needed for LEDs.
When does tolerance matter?
- Rarely, for an LED limiter or a pull-up, where a spread of values behaves much the same.
- More, for a voltage divider feeding an analog input, where the ratio of two resistors sets the reading. Poorly matched values shift every measurement.
- Quite a bit, where two resistors must balance each other, or in precision measurement circuits.
Temperature also shifts values slightly, and manufacturers publish how much. Again, datasheets are the place to confirm, and learning reading datasheets pays off here.
Voltage dividers and sensors
Many simple sensors, such as light-dependent resistors and thermistors, change their resistance with conditions. A microcontroller cannot read resistance directly; it reads voltage. So the sensor is paired with a fixed resistor in a voltage divider, and the voltage at the junction rises or falls as the sensor changes.
Two things shape the value you choose for the fixed resistor:
- Range. Pick a value near the middle of the sensor’s expected range so the output swings as widely as possible.
- Loading. A very large resistor makes the circuit sensitive to leakage and noise on the input; a very small one wastes current, which matters on batteries.
Ideal values depend on the specific sensor, so start from its datasheet and test. Because this is an analog measurement, the way analog digital signals are converted also limits how fine a reading you get.
What goes wrong with a poor choice
- Too low for an LED: excess current, possible overheating and early failure.
- Too high for an LED: the light is dim or seems off altogether.
- Too small a power rating: the resistor runs hot, changes value, or fails open or burns.
- Wrong divider ratio: readings are squeezed into a tiny range or exceed what the pin can accept, which can damage an input.
- Very high values on a pull-up: the pin can still pick up noise, so it may not behave as a firm default.
- Mixing up colour bands: the code is easy to misread, especially brown versus red or orange, so confirm with a meter.
Reading and checking values
Through-hole resistors use colour bands, and many beginners find it quicker to measure a resistor with a multimeter than to decode the bands. Take the reading with the resistor out of the circuit, since other parts can give false numbers. Surface-mount parts print a number code instead.
A tidy storage system helps too. Small labelled bags or a divided box prevent the common mistake of grabbing the wrong value from a mixed pile.
Safety
These examples use low-voltage hobby supplies. Resistors in mains-powered equipment, or anywhere with large currents, are a different matter: follow manufacturer guidance and local rules, and leave mains work to qualified people.