Pull-Up and Pull-Down Resistors Explained
Learn why digital inputs float, how pull-up and pull-down resistors set a safe default level, and how to choose the right value for buttons and buses.
On this page
A digital input pin looks simple. It reads a high level or a low level, and that is that. The trouble begins when nothing is driving the pin. A wire that connects to a button which is not pressed is not at zero volts, and it is not at the supply voltage either. It is undefined, and the processor may read it as high, low or a random mix that changes from moment to moment.
Pull-up and pull-down resistors solve this by giving the input a default level when nothing else is controlling it. They are some of the cheapest and most useful parts in any digital circuit.
The Floating Input Problem
A CMOS input has extremely high impedance. It draws almost no current and responds to tiny amounts of charge. If it is left unconnected, or connected only to an open switch, it behaves like an antenna. Nearby electric fields, your hand, or a passing signal can push its voltage up and down.
This is called a floating input. The result might be a button that seems to press itself, a counter that runs wild, or a device that behaves differently when you touch it. Floating inputs can also cause extra current draw, because the input stage may sit halfway between high and low.
Pull-Up Resistors
A pull-up resistor connects the input to the positive supply through a resistor. When nothing else drives the line, the resistor holds it at a high level.
For a button wired between the input and ground, the behavior is:
- Button not pressed: the resistor pulls the pin to the supply, and the input reads high.
- Button pressed: the pin is connected directly to ground, which overpowers the resistor, and the input reads low.
The resistor lets the switch work with only one side connected to anything. When the button closes, a small current flows from the supply through the resistor to ground. That current is the supply voltage divided by the resistance, so a larger resistor wastes less power.
Pull-Down Resistors
A pull-down resistor does the opposite. It connects the input to ground through a resistor, holding the line low by default.
With a button wired between the supply and the input:
- Button not pressed: the resistor pulls the pin to ground, and the input reads low.
- Button pressed: the supply connects to the pin and overpowers the resistor, so the input reads high.
Both arrangements work. The difference is the logic polarity. Pull-ups give an active-low button, where pressing reads as zero. Pull-downs give an active-high button.
Which One to Use
Pull-ups are more common in practice. Many older logic families sank current better than they sourced it, so pulling low was more natural, and many microcontrollers include internal pull-up resistors. Pull-downs are common when you want a line to default to off, such as the gate of a transistor that should stay off during startup or reset.
Choosing the Resistor Value
The value sets a balance between several needs.
- Too small (for example, a few hundred ohms): When the line is pulled to the opposite level, a large current flows and wastes power. It also makes the driver work harder.
- Too large (for example, several megohms): The resistor is weak, so noise and leakage can still disturb the pin, and signal edges become slow because of the pin's capacitance.
A typical range is from a few kilohms up to a few tens of kilohms, with 10 kilohms being a common choice for buttons. Open-drain buses such as I2C use smaller values, often in the range of a few kilohms, because they need faster rising edges.
You can estimate the rise time from the RC time constant: the pull-up resistance times the capacitance on the line. Higher resistance or more capacitance slows the rising edge.
Internal Pull Resistors
Most microcontrollers have optional internal pull-up or pull-down resistors that you can enable in software. They save parts and board space, which is convenient for buttons and simple inputs. Their values are usually fairly large and not very precise, often tens of kilohms, so they may be too weak for long wires, noisy places or fast buses. When in doubt, add an external resistor.
Where Else They Appear
- Open-drain and open-collector outputs: I2C lines, interrupt lines and wired-OR signals need a pull-up, because the output can only pull low.
- Reset and enable pins: A pull-up or pull-down guarantees a known state at power-up.
- Boot configuration pins: Many chips read specific pins at start to decide how to boot, and resistors set those pins.
- Unused inputs: Tie them to a defined level instead of leaving them floating.
- Unconnected connector pins and cable ends: A resistor prevents false triggers when a cable is unplugged.
Common Mistakes
- Leaving a button input with no resistor at all.
- Using an internal pull-up and then reading the wrong polarity in code.
- Choosing a pull-up for an I2C bus that is much too large for its capacitance.
- Forgetting that the supply voltage of the pull-up must match the logic level of the receiving chip.
- Using both a pull-up and a pull-down on the same line, creating an unintended voltage divider.
Frequently Asked Questions
Do I need a pull-up if my microcontroller has an internal one?
Not always. For a simple button on a short wire, the internal pull-up is usually enough. For long wires, noisy environments or fast buses, a stronger external resistor is more reliable.
What is the difference between pull-up and pull-down?
A pull-up resistor ties the line to the supply so the default state is high, and a pull-down ties it to ground so the default state is low. The one you pick decides whether a pressed button reads low or high.
Why do I2C lines use pull-ups instead of driving high?
Devices on an I2C bus only pull the lines low, which lets many devices share a wire without conflict. The pull-up resistors return the lines to high when nobody is pulling low.