Let’s say you have a µC with one pin configured as an input. If there is nothing connected to the pin and your program reads the state of the pin, will it be high (pulled to VCC) or low (pulled to ground)? It is difficult to tell. This phenomenon is referred to as floating. To prevent this unknown state, a pull-up or pull-down resistor will ensure that the pin is in either a high or low state, while also using a low amount of current.

A pull-up resistor is a resistor connected between a signal conductor and a positive power supply voltage to ensure that the signal will be at a proper logic level when external devices are disconnected or at high-impedance, Just because you have nothing at all connected to an input pin doesn't mean it is a logical zero. They may also be used at the interface between two different types of logic devices, possibly operating at different logic levels and power supply voltages.

A pull-up resistor pulls the voltage of the signal it is connected to towards its voltage source level. When the other components associated with the signal are inactive, the pull up prevails and brings the signal up to a logical high level. When another component on the line goes active, it overrides the pull-up resistor. The pull-up resistor ensures that the wire is at a defined logic level even if no active devices are connected to it.

A pull-down resistor works in the same way but it is connected to the ground. It holds the logic signal at a low logic level when no other active device is connected, practically; the pull-up resistors are more common than pull-down ones.

Fig1: pull-up resistor

Fig2: pull-down resistor

The principle that the pull-up and pull-down resistors work is almost the same, in the pull-up case the pull-up and pin resistors form a voltage divider, so R1 will have a portion of VCC, this portion must be high enough for the input pin to read a high state when the button is not pressed, also only a very small amount of current must flow from VCC through R1 and into the input pin. Below you will find out how to choose the proper resistor’s value. (When the button is pressed, the current will flow to the ground directly through R1 and a zero amount of current flows through R2, and the µC will read low logic level).

In the case of pull-down resistor, the pull-down and pin resistors are considered to be in parallel, so they will acquire the same voltage VCC, when the button is pressed, a higher amount of current will flow through the pull-down resistor R1, since it has a smaller value than the pin resistor R2, if you choose R1 to be significantly small, it will be closer to short circuit, so all the current will flow through it and the µC won’t be able to read the high logic level as it should do. (When the button is not pressed, almost a zero amount of current flows through R2 and R1, any undesired currents will flow through R1 to the ground)

Fig3: current flow when the button is not pressed  (Pull-up resistor)

Fig4: current flow when the button is not pressed (Pull-down resistor)

Fig5: current flow when the button is pressed (Pull-up resistor)

Fig6: current flow when the button is pressed (Pull-down resistor)

The value of a pull down or pull up/down resistors will vary depending upon your specific devices involved, as a general terms, the low resistor value is called a strong pull-up/down (more current flows), a high resistor value is called a weak pull-up/down (less current flows) (strong and weak concepts are from the pull-up/down resistor’s point of view). You don’t want the resistor’s value to be too low. The lower the resistance, the more power will be used when the button is hit. You generally want a large resistor value (10kΩ), at the same time you don’t want it to be too large, 4MΩ resistor might work as a pull-up, but its resistance is so large (or weak) that it may not do its job 100% of the time, in this case the µC may not be able to read high logic level, it may read it as if it is low logic or high impedance.

A rule of thumb is to use a resistor that is at least 10 times smaller than the value of the input pin impedance. In bipolar logic families which operate at operating at 5V, the typical pull-up resistor value is 1-5 kΩ. For switch and resistive sensor applications, the typical pull-up resistor value is 1-10 kΩ. A good starting point when using a switch is 4.7 kΩ. Some digital circuits, such as CMOS families, have a small input leakage current, allowing much higher resistance values, from around 10kΩ up to 1MΩ. The disadvantage of using a larger resistance value is that the input pin responses to voltage changes will get slower. This is because the system that feeds the input pin is essentially a capacitor coupled with the pull-up resistor, thus forming a RC filter, and RC filters take some time to charge and discharge. If you have a really fast changing signal (like USB), a high value pull-up resistor can limit the speed at which the pin can reliably change state. This is why you will often see 1k to 4.7KΩ resistors on USB signal lines.

Since pull-up resistors are so commonly needed, many MCUs, like the ATmega328 microcontroller on the Arduino platform, have internal pull-ups that can be enabled and disabled. To enable internal pull-ups on an Arduino, just use the code line:

PinMode (pin number, INPUT_PULLUP);

If you try typing INPUT_PULLDOWN your program won’t work, because there no such hardware, the hardware that do exist is an internal pull-up resistor.

Calculating a Pull-up Resistor Value:

Let’s say you want to limit the current to approximately 1mA when the button is pressed in the circuit in Fig1, where Vcc = 5V. What resistor value should you use?

It is easy to show how to calculate the pull-up resistor using Ohm’s Law, since the pull-up resistor is in series with the pin resistor, then the same current will flow through both resistors, this current is found to be:

And since the only unknown is R1, so it will be found as follows:

But in the case of pull-down resistor, such as in Fig2, the calculation is a little bit different, R1 and R2 are in parallel, so they will acquire the same voltage, they are called current divider, so when pressing the button a portion of the total current will flow through R2, so the calculation will be as follows:

We have two unknowns, I1 and R1, pick up I1 (choose some value, say 0.5mA for our discussion) so R1 will be:

Remember to convert all of your units into SI units (volts, amps and Ohms) before calculating (e.g. 1mA = 0.001 Amps), it is worthy to check the datasheet for your µC (or whatever IC you are using) to lock for the value of the pin resistor, sometimes it is referred to as the internal input impedance or just input impedance.

In our discussion we used the µC to demonstrate the effect of pull-up/down resistors, what applies for µC applies for any integrated circuit (IC).