a pull-up resistor
A pull-up resistor is a gentle resistor connected from a signal line to the positive supply, whose job is to hold the line HIGH whenever nothing else is actively pulling it LOW. Think of a lightweight spring that keeps a door closed: anyone can push the door open against the spring, and the moment they let go the spring eases it shut again. The pull-up gives a wire a defined resting state instead of leaving it floating and at the mercy of noise.
It is the indispensable partner of an open-drain output. The transistor can only pull the line down; the pull-up provides the upward force. When the transistor is off, current flows from the supply through the resistor onto the line and any input capacitance, settling the line at HIGH. When the transistor turns on, it overpowers the weak resistor and yanks the line to near ground. Sizing is a tradeoff: a small resistor (say 1 kΩ) pulls up fast and is noise-immune but wastes more current and demands the transistor sink more (5 V / 1 kΩ = 5 mA when LOW); a large resistor (say 100 kΩ) sips current but charges the line's capacitance slowly, blurring fast edges. A typical compromise is 4.7 kΩ to 10 kΩ. A pull-down resistor is the mirror image: tied to ground, it holds a line LOW at rest.
Pull-ups appear everywhere: on every open-drain bus line (I2C needs one per line), on a microcontroller reset pin so it does not float, on pushbuttons so an unpressed button reads a clean HIGH, and on unused logic inputs so they never drift. The honest pitfall is forgetting one — a floating input or bus line is not LOW, it is undefined, and it will behave erratically as it picks up hum and crosstalk. Many microcontrollers offer weak internal pull-ups (20 to 50 kΩ) you can switch on in software, saving a part but with less control over the value.
A pushbutton wired from a microcontroller input to ground, with a 10 kΩ pull-up to 3.3 V: released, the pin reads HIGH (3.3 V through the resistor); pressed, the button shorts the pin to ground for a clean LOW. Without the pull-up, the released pin floats and reads garbage.
A weak spring to HIGH; anything stronger can pull it LOW.
Smaller pull-up means faster edges and more noise immunity but more wasted current and a heavier load on whatever pulls LOW. There is no universally right value — it depends on bus speed, capacitance, and power budget.