Hardware

Pull Up vs Pull Down Resistor: What's the Difference?

A pull-up resistor connects an input pin to the supply voltage so it reads HIGH when nothing else drives it, and a pull-down resistor connects it to ground so it reads LOW. Use a pull-up when your switch connects the pin to ground, and a pull-down when your switch connects the pin to the supply.

Both do the same job: they stop an input from floating. The only difference is which logic level the pin sits at when the switch is open or the sensor is idle.

Why a digital input needs one

A digital input pin measures a voltage and decides whether it counts as HIGH or LOW. If nothing is connected to the pin, the voltage is not defined. The pin is "floating": it picks up noise from your fingers, nearby wires and other signals, and the reading can flip between HIGH and LOW with no real input at all.

A push button alone does not fix this. When the button is pressed it connects the pin to a known voltage, but when it is released the pin is connected to nothing. You need a resistor to give the pin a default level while the button is open. The resistor is weak on purpose, so that the button can overpower it when pressed.

Pull-up resistor: idle HIGH, pressed LOW

Wire the resistor between the input pin and the supply voltage (for example 5 V or 3.3 V), and wire the button between the input pin and ground.

  • Button open: no current flows through the resistor, so the pin sits at the supply voltage and reads HIGH.
  • Button closed: the pin is connected straight to ground, and the resistor limits the current that flows from the supply to ground. The pin reads LOW.

The logic is inverted from what many beginners expect: pressing the button gives LOW. This is called "active low".

Pull-down resistor: idle LOW, pressed HIGH

Wire the resistor between the input pin and ground, and wire the button between the input pin and the supply voltage.

  • Button open: the resistor pulls the pin to ground, and it reads LOW.
  • Button closed: the pin is connected to the supply voltage, and it reads HIGH. The resistor again limits the current, this time from the supply to ground.

This is "active high", and it is the more intuitive behaviour: pressed means 1. The cost is that you usually need an external resistor, because many microcontrollers offer internal pull-ups but fewer offer internal pull-downs.

Side by side

Pull-upPull-down
Resistor connects pin toSupply voltageGround
Switch connects pin toGroundSupply voltage
Reading with switch openHIGHLOW
Reading with switch closedLOWHIGH
Logic styleActive lowActive high

How to choose the resistor value

The value is a trade-off between two things. A smaller resistor holds the pin more firmly at its idle level, which helps against noise. A larger resistor wastes less current when the switch is closed. The current through a closed switch is the supply voltage divided by the resistance, which you can check yourself:

  • 5 V across 10 kilohms: 5 / 10,000 = 0.5 mA
  • 3.3 V across 10 kilohms: 3.3 / 10,000 = 0.33 mA
  • 5 V across 1 kilohm: 5 / 1,000 = 5 mA

10 kilohms is the usual starting point for a switch on a short wire. Very long wires or noisy environments may justify a smaller value. Always check the datasheet of the part you are connecting for its input current limits.

Use the internal pull-up instead of a resistor

Many microcontrollers have pull-up resistors built into their pins, so a button needs no external parts. On Arduino you enable the internal pull-up with the INPUT_PULLUP mode. The Arduino reference for pinMode() says that it is possible to enable the internal pullup resistors with the mode INPUT_PULLUP, and that the INPUT mode explicitly disables them.

Wire the button between the pin and ground, then read the pin. Arduino's Input Pullup Serial example does this on pin 2:

void setup() {
  Serial.begin(9600);
  pinMode(2, INPUT_PULLUP);
  pinMode(13, OUTPUT);
}

void loop() {
  int sensorValue = digitalRead(2);
  Serial.println(sensorValue);
  digitalWrite(13, sensorValue);
}

With the internal pull-up active and connected to 5 V, the pin reads HIGH when the button is open. When the button is closed, the pin reads LOW because a connection to ground is completed. Your code has to treat LOW as "pressed". The example above is adapted from Arduino's page and prints 1 when released and 0 when pressed.

A common mistake is to call pinMode(pin, INPUT) and then expect a pull-up. Plain INPUT leaves the pin floating, so you either add an external resistor or switch to INPUT_PULLUP.

Pull-up and pull-down on a Raspberry Pi

Raspberry Pi boards let you choose in software. The Raspberry Pi documentation says that after a power-on reset, GPIO pins are generally set as inputs with default pull states applied, and that you can control the pull-up or pull-down configuration for other pins through software. The exception is GP2 (SDA) and GP3 (SCL), which have fixed 1.8 kilohm resistors, so do not rely on changing their pull in software.

The internal resistors are fairly large, and the value depends on the chip. The same documentation lists these figures for the pull-up and pull-down resistors:

ChipExample boardsInternal pull resistance
BCM2835, BCM2836, BCM2837, RP3A0Pi Zero, Pi 3B+50 to 65 kilohms
BCM2711Pi 4, Pi 40033 to 73 kilohms
RP1Pi 5Pull-up 37 / 55 / 86 kilohms, pull-down 35 / 55 / 98 kilohms (min / typical / max)

Because these resistors are much larger than a typical 10 kilohm external one, they are more easily overpowered by noise. For a short wire to a button they are fine. For a long cable, use an external resistor.

Which one should you pick?

  • Your chip has an internal pull-up and you are wiring a button: use the pull-up and connect the button to ground. It needs no extra parts.
  • You want pressed to read HIGH: use a pull-down, and add an external resistor if your chip does not offer an internal one.
  • The pin is shared with other circuitry, or has a special function: read the datasheet first. Some pins already have a fixed resistor, an LED or another load attached.

If the input still reads randomly

Check that the resistor goes to the right rail: a pull-up wired to ground, or a pull-down wired to the supply, does the opposite of what you intend. Confirm the resistor is actually connected to the same pin as the button, not a neighbouring one. Then confirm your code treats the correct level as "pressed". With a pull-up the active level is LOW. If the reading flickers only when you press or release the button, that is contact bounce in the switch itself, which a pull resistor does not fix.

Frequently asked questions

Which is better, a pull-up or a pull-down resistor?
Neither is better in general. A pull-up makes the idle state HIGH and the active state LOW, a pull-down does the reverse. Pick the one that matches how your switch or sensor is wired. Many microcontrollers have internal pull-ups built in, which is why active-low buttons are so common.
What value should a pull-up or pull-down resistor be?
10 kilohms is a common starting value for a switch input. It is small enough to hold the pin firmly at its idle level and large enough that a pressed button wastes little current: at 5 V, a 10 kilohm resistor passes 0.5 mA through a closed switch. Check your device's datasheet for any limits.
Can I use both a pull-up and a pull-down on the same pin?
You can, but the two resistors then form a voltage divider and the pin sits at a voltage between HIGH and LOW. That is rarely what you want for a digital input. Use one or the other.
What happens if I leave an input pin unconnected?
The pin is floating. Its voltage is not defined, so digitalRead() or the equivalent can return HIGH or LOW at random and change as you touch the wire or as nearby signals change. A pull-up or pull-down resistor removes the ambiguity.

Sources