Resistor color code calculator
All tools

Pull-Up vs Pull-Down Resistors for Microcontrollers

A digital input that is not connected to anything does not read as zero; it reads whatever noise it picks up. One resistor fixes that, and its value matters more than most tutorials let on.

By the Feeed team · · 7 min read

Wire a push button between an Arduino pin and ground, print the pin state, and you may see it flicker between HIGH and LOW while nobody touches anything. Move your hand near the wires and it changes again. Nothing is broken: the input is floating. A pull-up or pull-down resistor gives it a defined state, and choosing that resistor well is a small design decision with real consequences for power, noise and speed.

The floating input problem

A microcontroller input pin is the gate of a CMOS transistor pair. It has extremely high impedance and draws only a tiny leakage current, from nanoamps up to around a microamp. With nothing connected, the pin's voltage is set by whatever charge happens to collect on it: mains hum from nearby wiring, crosstalk from neighboring traces, static from your hand. The reading becomes random.

There is a power cost too. If a floating input drifts to around half the supply voltage, both transistors in the input stage can conduct partially at once, drawing extra current. On a battery-powered project that sleeps most of the time, a few floating pins can noticeably shorten battery life.

A switch only connects the pin to something while it is pressed. When it is released, the pin floats. The fix is a resistor that holds the pin at a known level by default and is easily overpowered when the switch closes.

Pull-up versus pull-down

A pull-up resistor connects the pin to the supply, and the switch connects the pin to ground. Released, the pin reads HIGH; pressed, the switch pulls it LOW. This is called active-low, and it is the more common arrangement.

A pull-down resistor connects the pin to ground, and the switch connects the pin to the supply. Released, the pin reads LOW; pressed, it reads HIGH.

In both cases the resistor is what stops a short circuit. When the switch closes, current flows from the supply through the resistor to ground, limited to V / R. With a plain wire in place of the resistor, pressing the button would short the supply.

Pull-ups are preferred for a few reasons. Many microcontrollers have built-in pull-ups, while built-in pull-downs are less universal. Open-drain buses such as I²C only work with pull-ups. And with the switch going to ground, the wire out to the button carries ground rather than the supply, so a chafed wire touching a metal case does no harm.

Pull-downs have their own classic job: holding a MOSFET gate low. While a microcontroller resets or boots, its pins are usually high-impedance inputs, and a floating gate can switch a load on at random. A resistor of 10 kΩ to 100 kΩ from gate to source keeps the MOSFET off until the pin takes control; a 100 kΩ part is a common choice.

Choosing a value

The resistor value is a trade-off. When the switch is closed, the resistor draws V / R from the supply:

ResistorCurrent at 3.3 VCurrent at 5 VTypical use
1 kΩ3.3 mA5.0 mAstrong pull for noisy or long lines; wasteful otherwise
4.7 kΩ0.70 mA1.06 mAI²C buses, cables a few meters long
10 kΩ0.33 mA0.50 mAthe general-purpose default for buttons
47 kΩ70 µA106 µAbattery-powered inputs
100 kΩ33 µA50 µAvery low power, short wires, MOSFET gates

A lower value holds the pin more firmly. Noise has to inject more current to move the voltage, and the pin recovers faster because the resistor charges stray capacitance quickly. The cost is current: more drain on a battery, and more load on any output that has to drive the line against the resistor.

A higher value saves current but weakens the pull. Input leakage flowing through the resistor creates a voltage drop: 1 µA through 100 kΩ is 0.1 V, harmless, but through 1 MΩ it is 1 V, enough to threaten a valid HIGH at 3.3 V. The resistor also forms an RC circuit with the capacitance of the pin and wiring. 100 kΩ with 100 pF of cable gives a 10 µs time constant, fine for a button but too slow for a fast signal.

10 kΩ is the classic compromise. At 3.3 V it draws 3.3 / 10,000 = 0.33 mA while the button is held, which is 3.3 × 0.00033 ≈ 1.1 mW. At 5 V it is 0.5 mA and 2.5 mW. That is negligible for a button pressed now and then.

10 kΩ ±5% resistor: Brown-Black-Orange-Gold

It stops being negligible when the switch is closed most of the time, such as a door sensor whose reed switch stays shut while the door is closed. A 10 kΩ pull-up at 3.3 V then draws 0.33 mA continuously, about 7.9 mAh per day, enough to drain a 2,000 mAh battery pack in roughly 250 days on its own. A 100 kΩ pull-up cuts that to 0.79 mAh per day, small next to the battery's own self-discharge. If the input is also driven by another circuit through its own resistance, the pull-up forms a divider with it; the voltage divider calculator shows what voltage the pin actually sees.

Internal pull-ups

Most microcontrollers can switch on a pull-up inside the chip, which saves a part. On an Arduino, pinMode(2, INPUT_PULLUP); enables it, and digitalRead(2) == LOW then means the button is pressed. On many microcontrollers these internal resistors are roughly 20 to 50 kΩ, and the exact value varies with the chip, the supply voltage and temperature, so check the datasheet. Raspberry Pi GPIO pins also have software-selectable pull-ups and pull-downs in the tens of kilohms. One Raspberry Pi detail: GPIO2 and GPIO3, the I²C pins, have 1.8 kΩ pull-ups to 3.3 V fitted on the board, so they read HIGH even with the internal pull-down selected.

Internal pull-ups are fine for buttons on short wires on the same board. They are weak for long cables, for anything near motors or relays, and for fast open-drain buses. In those cases add an external 4.7 kΩ to 10 kΩ resistor. Leaving the internal pull-up enabled as well does no harm; it simply sits in parallel.

Sizing I²C pull-ups

The SDA and SCL lines of an I²C bus are open-drain: devices can only pull them low, and the pull-up resistors bring them high again. Without pull-ups the bus does not work at all. Their value is bounded on both sides.

The upper limit comes from rise time. The resistor charges the bus capacitance (wiring plus roughly 10 pF per device pin, with 400 pF the maximum the specification allows), and the rise time is about 0.85 × R × C. Standard mode at 100 kHz allows 1,000 ns and fast mode at 400 kHz allows 300 ns. So R(max) = t(rise) / (0.85 × C). For 100 kHz with 200 pF that gives about 5.9 kΩ; with 100 pF, about 11.8 kΩ. For 400 kHz with 100 pF it is about 3.5 kΩ.

The lower limit comes from how much current a device can sink while still producing a valid LOW, typically 3 mA at no more than 0.4 V. R(min) = (V − 0.4) / 0.003, which is about 967 Ω on a 3.3 V bus and 1.53 kΩ on a 5 V bus.

That is why 4.7 kΩ is the usual choice for a small 100 kHz bus, 2.2 kΩ suits 400 kHz or longer wiring, and 10 kΩ only works on very short, slow buses. Watch out for breakout modules that include their own pull-ups. Three modules with 4.7 kΩ each give 4.7 / 3 ≈ 1.57 kΩ in parallel, right at the 5 V lower limit; many boards have solder jumpers to disconnect the extras. Pull the lines up to the bus voltage all devices share, and use a level shifter when mixing 3.3 V and 5 V parts.

Pull-ups and debouncing

A pull-up defines the idle state; it does not stop contact bounce. Mechanical contacts chatter for a few milliseconds when they open or close, and a fast loop can count one press as several. The usual fix is in software: after the first change, ignore further changes for 20 to 50 ms.

A hardware alternative is a capacitor from the pin to ground. With a 10 kΩ pull-up, 100 nF gives a 1 ms time constant, which smooths short bounces. Add about 100 Ω in series with the switch to limit the discharge current; the pressed voltage is then 5 × 100 / 10,100 ≈ 0.05 V, still a solid LOW. Because the edge is now slow, a Schmitt-trigger input helps keep it clean. Avoid large capacitors with weak internal pull-ups: 1 µF with 40 kΩ gives a 40 ms time constant, slow enough to make a button feel laggy.

Pull-up resistors are among the most common parts on any hobby board, so it pays to recognize a 10 kΩ brown, black, orange or a 4.7 kΩ yellow, violet, red on sight; the resistor color code calculator confirms any band combination. For the output side of the same projects, the LED resistor guide covers current-limiting resistors, and the Ohm's law calculator checks currents like the ones above.

Identify a resistor by its color bands →