How and why to add pull-up and pull-down resistors to Microcontroller I/O pins

Image: 

Resistor “Pull-ups” and “Pull-downs” serve many purposes in electronics. A pull-up is a resistor with one end wired to a positive power rail. A pull-down has one end wired to ground or a negative rail. Here is a basic introduction with schematics. A wikipedia entry covers this but is full of arcana like ttl logic gates.

For Analog to Digital Convertor inputs they are often used to establish a controlled current flow into a resistive sensor such as a fabric pressure sensor, FSR (force (sic) sensing resistor) or LDR (light dependent resistor). A controlled current flow is required in these sensors because ADC’s measure voltages so the Very Important Result (V=I.R) can be used to infer resistance from resistance changes. However the result is not a linear relationship between measured voltage and sensor resistance (the non-inverting op-amp is needed for that) but the low cost of resistors makes this a popular choice.

For switch inputs a pull-up can be used to establish a high or “1” value that the switch shorts to ground to establish the low or “0” value.

Pull-downs are often used on outputs to establish a known output impedance.

For digital I/O using the i2c protocol a pull up is used so that a single pin can serve as input or output.

Steps: 

Decide whether your application requires a pull-up, pull-down or both.
For sensor and switch applications it is common practice to use two wires to the sensor, one of them being ground. A pull-up is required in this case , i.e. a resistor connected to a positive power rail, e.g. 5V.

A good application for both is for establishing the three states of a double throw switch. Wire the outer leads of the switch to the power rails (5V and ground) and wire the pull up and pull down and ADC input to the center conductor of the switch. The ADC input will vary between 5v, 0V and somewhere in between when the the switch contacts are between the two poles. This could be used to estimate velocity in a music keyboard switch for example.

Choose the resistor values according to various rules of thumb:

Maximum Resistance to be Measured

For resistive sensor inputs pick a value comparable to the maximum value the variable resistor will have. Be careful of values less than 1kohm as the sensor may heat up. Values greater than 500Kohm may require slow acquisition times of the ADC.

10K

For switch inputs and many resistive sensors 10K-20K is a very common range of values.

Equal up and Down

Identical pull-ups and pull-downs of 10k-100K to establish an approximate half rail voltage are very common in both microcontroller input applications and single-supply op-amp circuits.

Further circuits for resistive sensors like FSR’s can be found in the FSR Integration Guide.