Complexity of David

Data Science, Machine Learning, Artificial Intelligence, Visualization, and Complex Systems.

What Are Pull-Up and Pull-Down Resistors?

Most of the inputs (sensors) connected to Arduino work by exploring some kind of Voltage Divider.

Voltage Divider

As the name gives it away, a voltage divider splits the voltage of a circuit in two parts.

Voltage Divider

in the above circuit, the voltage betweenand ground is divided at. The value ofis dependent on the resistorsandvia:

Pull-Up Resistor and Pull-Down Resistor

Imagine that you replace eitherorwith a switch (but not simultaneously). When the switch opens the circuit the value ofis “pulled” to the voltage present on the resistor side. If theis replaced by a switch,is a pull-up resistor, if instead the switch replaces, thenpulls-down the voltage to ground.

Pull-up and pull-down resistors are useful because without them the inputs that readwould be floating without a reference to measure when the switch was open. And when that same switch closed without the resistor in series there would be a short-circuit betweenand ground.

What if I don’t use a pull-down with a switch?

Pull-up/down resistors stop the circuit from floating. Frequently new users setup a switch in series between 5V and the input PIN on Arduino, without a pull-down resistor. They assume the PIN to be at ground level. This is wrong.

The input PIN is floating. This means that its reading will be subject to whatever momentary internal currents are flowing through the internals of the Arduino. If you try to setup the switch in this way you’ll find that it will act in an apparently random way. It might read LOW most of the time, but sometimes it will read HIGH with the switch open. Not desirable at all. ALWAYS USE A PULL-DOWN/UP RESISTOR.