Pull-ups, floating inputs & debouncing
A digital input connected to nothing doesn’t read 0. It floats, drifting with electrical noise, stray capacitance, even a hand nearby. A floating input returns random values and can make a system behave erratically. The fix is a pull-up or pull-down resistor: a gentle tie, typically around 10 kΩ, to the supply or to ground. It defines the line’s idle state while staying weak enough for any real driver to override.
Pull-ups also enable a whole signaling style. Open-drain outputs can only pull a line low; a shared pull-up resistor provides the high. That lets many chips safely share one wire, since whoever pulls low wins. The I2C bus works exactly this way, and an I2C bus with missing pull-ups simply doesn’t function.
Mechanical switches bring a related problem: bounce. Closing contacts physically rattle for a few milliseconds, producing a burst of rapid on-off transitions that fast logic happily counts as many presses. Debouncing filters that burst into one clean event, either with an RC circuit in hardware or with firmware that ignores changes for a few tens of milliseconds after the first edge.
Key points
- Floating inputs read random noise. Every input needs a defined idle state.
- Pull-up and pull-down resistors (around 10 kΩ) set that state while letting drivers override it.
- Open-drain buses like I2C depend on pull-ups. Without them the bus is dead.
- Switch contacts bounce for milliseconds. Debounce in hardware or software so one press reads once.
Practice
0 of 2 answered · Not startedWrong answers just let you try again, and hints are there if you want them. Answering every question first time, without hints, is what earns mastery.
- 1
A button connects a pin to ground when pressed. What does the pin read when it is not pressed and has no pull-up?
- 2
Why does a mechanical switch need debouncing?
