Choosing the resistor: LEDs, pull-ups and pull-downs

An LED resistor comes from Ohm’s law on the leftover voltage: supply minus forward voltage, divided by the current you want. A 2 V red LED at 20 mA on a 5 V supply needs (5 − 2) ÷ 0.02 = 150 Ω. A pull-up comes from a window between two limits. A pull-down comes from a trade between wasted current and noise immunity. Same component, three different methods.

Getting the method right matters more than getting the value exact, because two of the three have a range of correct answers rather than a single one.

What forward voltage should you use?

The one for the colour, because it follows the band gap of the semiconductor and varies more than people expect.

LED colour Typical forward voltage
Red 1.8–2.1 V
Yellow 2.0–2.2 V
Green 2.0–2.2 V
Blue 3.0–3.4 V
White 3.0–3.4 V

This is why using a red LED figure for a white one on a 3.3 V rail produces a negative resistor value: there is no voltage left over. A white LED on 3.3 V needs a constant-current driver or a higher supply, not a smaller resistor.

Round the resistor up rather than down. A slightly larger resistor gives slightly less current and a slightly dimmer LED; a smaller one runs it above its rating, which shortens its life for a brightness difference the eye can barely detect.

Can two LEDs share one resistor?

In series, yes — the same current flows through both, so add the forward voltages and work from what is left. Two 2 V red LEDs on 5 V leave 1 V for the resistor, which at 20 mA is 50 Ω.

In parallel, no. LEDs are not resistors: small differences in forward voltage mean one takes most of the current, runs hotter, drops slightly further, and takes more still. Each parallel LED needs its own resistor, which is why LED strips have one per group of three.

What sets a pull-up value?

Two limits, and the answer is the window between them.

  • The minimum is set by how much current the driver can sink: supply voltage divided by the sink current. Below that, the open-drain driver cannot pull the line low enough to register.
  • The maximum is set by rise time. The resistor and the bus capacitance form an RC pair, and the line must reach a valid high within about 30 per cent of a bit period.

For a 3.3 V bus running at 400 kHz with 100 pF of capacitance, that window is roughly 1.1 kΩ to 5.6 kΩ. Too weak and the line rises too slowly, so the receiver samples a level that has not arrived — which shows up as intermittent errors that get worse as you add devices or lengthen wires. Too strong and the driver cannot pull it down.

This is why adding devices to a bus can break it. Every device adds capacitance, which pushes the maximum resistance down, and a value that worked with three devices may not work with eight.

Is a pull-down just an inverted pull-up?

No, because most digital inputs are not symmetric. CMOS inputs leak only nanoamps, so an extremely high pull-down would technically work — until board contamination, humidity and nearby switching noise couple into what is now a very high-impedance node.

Ten kilohms is the usual answer, and the reason is the trade rather than any calculation. A 10 kΩ pull-down on a 3.3 V rail wastes 0.33 mA whenever the line is driven high, which is nothing on mains power and significant on a coin cell.

On battery power the calculation is worth doing. A 0.33 mA continuous drain is about 2.9 Ah a year, which is more than a CR2032 holds several times over — so a battery design either uses a much higher value with careful layout, or switches the pull-down off when it is not needed.

Which resistor gets hot?

Rarely any of these. An LED resistor dropping 3 V at 20 mA dissipates 60 mW, comfortably inside a standard quarter-watt part. A pull-up or pull-down at these values dissipates single-digit milliwatts.

The exception is a dropping resistor carrying real current. The same 3 V drop at 500 mA is 1.5 W, which needs a deliberately chosen part and somewhere for the heat to go — and at that point a regulator is almost always the better answer.

Questions people ask

Can I use the microcontroller internal pull-ups? For a button, usually. For a fast bus, usually not — internal pull-ups are typically tens of kilohms, well above the maximum for anything running at speed.

Pull-up or pull-down? Whichever makes the inactive state safe. A button to ground with a pull-up is the common arrangement because a disconnected wire reads as inactive rather than as pressed.

Do I need one on a MOSFET gate? Yes, if anything can leave the gate floating. A floating gate drifts into partial conduction, which is how a MOSFET gets hot without anyone switching it on.

What wattage resistor? Quarter watt covers almost all of this. Work out the dissipation and choose a part rated at least twice it, which gives margin for the tolerance and for the ambient temperature.

Three questions, three methods, one component. The LED resistor calculator works from forward voltage and current, the pull-up resistor calculator reports the window rather than a single value, the pull-down resistor calculator shows the current each choice wastes, and the LED power calculator covers the strips where the driver does this for you.