Concept explainer · Beginner · 3 min read
Pull-Up and Pull-Down Resistors
Why Floating Pins Misbehave
By Geekobot Learning Team · Updated 24 Oct 2026
On this page
A pull-up resistor connects an input pin to the supply so it reads HIGH when nothing drives it; a pull-down connects it to ground so it reads LOW. Without one, an unconnected input "floats" and reads random values. 10 kΩ is the usual value for buttons. Most microcontrollers have internal pull-ups you can enable with INPUT_PULLUP, so wire the button between the pin and ground.
Key specs at a glance
- Typical value
- 10 kΩ for buttons and switches; 4.7 kΩ for I2C; 1 to 2 kΩ for noisy or fast lines
- Internal pull-ups
- Arduino about 20 to 50 kΩ; ESP32 about 45 kΩ; Pico about 50 kΩ
- INPUT_PULLUP
- pinMode(pin, INPUT_PULLUP): pressed button reads LOW
- Internal pull-downs
- ESP32 and Pico yes; classic Arduino no
- Current through 10 kΩ at 5 V
- 0.5 mA when the switch is closed
Why a floating input reads randomly
A digital input with nothing connected is like a microphone for electrical noise: your hand, nearby wires and mains hum push it above and below the threshold, so the pin flickers between HIGH and LOW. A pull-up or pull-down resistor gives it a definite resting level while still letting a switch or sensor override it.
Pull-up vs pull-down wiring
| Pull-up | Pull-down | |
|---|---|---|
| Resistor goes | Pin to VCC | Pin to GND |
| Switch goes | Pin to GND | Pin to VCC |
| Idle reading | HIGH | LOW |
| Pressed reading | LOW | HIGH |
| Internal version | INPUT_PULLUP on all boards | INPUT_PULLDOWN on ESP32, Pico, R4 |
| Common use | Buttons, I2C, open-drain outputs | Logic where idle must be 0, some sensor modules |
- Resistor goes
- Pull-up:
- Pin to VCC
- Pull-down:
- Pin to GND
- Switch goes
- Pull-up:
- Pin to GND
- Pull-down:
- Pin to VCC
- Idle reading
- Pull-up:
- HIGH
- Pull-down:
- LOW
- Pressed reading
- Pull-up:
- LOW
- Pull-down:
- HIGH
- Internal version
- Pull-up:
- INPUT_PULLUP on all boards
- Pull-down:
- INPUT_PULLDOWN on ESP32, Pico, R4
- Common use
- Pull-up:
- Buttons, I2C, open-drain outputs
- Pull-down:
- Logic where idle must be 0, some sensor modules
Reading a button with INPUT_PULLUP
Wire the button between the pin and ground; no external resistor needed.
const int BTN = 2;
void setup() {
pinMode(BTN, INPUT_PULLUP); // idle HIGH
pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
bool pressed = digitalRead(BTN) == LOW; // LOW when pressed
digitalWrite(LED_BUILTIN, pressed);
}Choosing the resistor value
A pull-up forms a voltage divider with whatever pulls the pin the other way, so it must be:
to hold the pin firmly against leakage and noise. Below about 100 kΩ for most inputs; 10 kΩ on long wires or near motors.
not to waste current or overload the device pulling it low. 10 kΩ at 5 V passes 0.5 mA when a button is pressed, which is negligible.
, 4.7 kΩ at 100 kHz, lower for 400 kHz or many devices. See I2C.
(ESP32 GPIO 0, 2, 12, 15; ESP8266 D3, D4, D8), check that your pull direction matches the boot requirement.
Open-drain outputs need pull-ups
Some outputs can only pull low: I2C lines, many sensor interrupt pins, the DS18B20's data line, and the ESP32's GPIO 34 to 39 inputs have no internal pull-ups at all. Those need an external pull-up to the logic supply. The symptom of a missing one is a line that never goes high, or a sensor the bus scanner cannot find.
Try it: I2C pull-up calculator
Change the values and the diagram and results update as you type.
Common mistakes to avoid
- Leaving an input floating and blaming the code for random triggers.
- Wiring the button to VCC while using INPUT_PULLUP, so the pin is always HIGH and the button does nothing.
- Pulling an ESP32 strapping pin the wrong way and stopping it from booting.
- Using a very weak pull-up (1 MΩ) on a long wire, so noise still gets through.
- Expecting internal pull-ups on ESP32 GPIO 34 to 39 or on analog-only pins.
Frequently asked questions
What is a pull-up resistor used for?
To hold an input pin at a known HIGH level when nothing else drives it, so buttons, switches and open-drain devices give clean readings.
What value should a pull-up resistor be?
10 kΩ for buttons and general inputs, 4.7 kΩ for I2C. Lower values are more noise-resistant but use more current.
Should I use pull-up or pull-down for a button?
Pull-up is the usual choice because every microcontroller has internal pull-ups: wire the button to ground, use INPUT_PULLUP, and read LOW as pressed.
Does the Arduino have internal pull-down resistors?
Classic AVR Arduinos (Uno, Nano, Mega) have only pull-ups. The ESP32, Raspberry Pi Pico and Arduino Uno R4 have both.
Why does my sensor's interrupt pin never go high?
Many interrupt and data pins are open-drain and need an external pull-up resistor, typically 10 kΩ to the sensor's supply voltage.
Parts for this guide
Calculators
Terms in this guide
Keep learning
Sources
- ATmega328P datasheet, I/O ports chapter (Microchip)
- ESP32 Series Datasheet, GPIO section (Espressif Systems)
- RP2040 datasheet, GPIO pads (Raspberry Pi Ltd)
Written by the Geekobot team from manufacturer datasheets. Always check the datasheet for the exact part and variant you buy.



