Home / Learn Embedded C / Pull-Up and Pull-Down Resistors

Pull-Up and Pull-Down Resistors

Keeping an input pin at a known, stable level when nothing is actively driving it.

The gistKeeping an input pin at a known, stable level when nothing is actively driving it.

The idea, explained simply

The basic idea

A pull-up or pull-down resistor connects an input pin weakly to a known voltage (high or low) so the pin reads a defined level when nothing else is actively driving it, instead of "floating" at an unpredictable value.

Why this comes up

A button wired to only connect a pin to ground when pressed will read an undefined, noisy value when NOT pressed unless a pull-up resistor holds it HIGH in that state — this is one of the most common early hardware bugs.

The mechanics

Many microcontrollers include a configurable internal pull-up or pull-down resistor on each GPIO pin, avoidable without any extra external component — selected via a configuration register alongside direction.

Where it is used

  • Button/switch wiring
  • Unused pin configuration
  • Noise-free input reads

Try it

Simulating a button read with a pull-up assumptionC: edit and run

With a pull-up resistor, the resting (unpressed) state reads HIGH, and pressing the button pulls it LOW — hence checking for LOW to detect a press.

Tip:A pin left "floating" (no pull-up, no pull-down, nothing externally driving it) can read randomly as HIGH or LOW due to electrical noise — always pull an unconnected or switch-only input to a known level.

Try it: comparing pull-up vs pull-down wiring choices

Choosing active-high or active-low logic based on pull typeC: edit and run

Pull-down wiring flips the polarity compared to pull-up wiring: the same code must check the opposite level.

Quick check

1. What problem does a pull-up or pull-down resistor solve for an input pin?