A question I get asked frequently by people new to circuit design is about pull-up and pull down resistors.
What is the purpose of a pull-up or pull down resistor, and how does it work?
I’ll try to answer this question here as simply as I can. When I think about this, it really is simple.
Here it goes:
Imagine that you have a switch. One pin is connected to a 5V source, and the other to a logic circuit. A logic circuit is a component that expects certain values only at its pins, usually HIGH or LOW, and it doesn’t really work well with anything else. An example could be an ATMega micro-controller, like the one you find in an Arduino board.
Schematically, you would have something like this:
This looks fine, the switch is closed and the input of the logic circuit is directly connected to Vin, so it is HIGH. No problem! What if we open the switch?
Well, now there is a problem. The input of the logic circuit is not connected to anything with a specific value, it’s just hanging there. Another term people often use for this kind of situation is “floating”.
Let’s repeat: the problem here is that the input of the logic circuit is not connected to a source of defined value, and logic circuits really don’t like this!
So how do we fix it? Have a look at the next schematic:
We fix this by using a large resistor (say, 10kΩ or larger) to connect the input of the logic circuit to ground. When the switch is open, instead of the input to be floating to an uncertain value, it becomes grounded, therefore LOW, through the resistor.
What if the switch closes again? Then, we’ll have this:
Because the resistor is large, current from Vin will find it much easier to flow through the logic circuit rather then to ground via the resistor. Because the connection between Vin and the logic circuit input has negligible resistance, the Vin’s HIGH value will be transferred to the input of the logic circuit.
To recap, by attaching a pull-down resistor to our circuit, we ensure that the logic circuit’s input will always have a defined value, and will be happy.
You could inverse the circuit and connect the resistor to Vin instead of ground. Now, this resistor would be called “pull-up”, because it would be pulling the input of the logic circuit to Vin (HIGH) when the switch was open.
A pull-up resistor schematic would look like this: