Tag Info

Refers to pull-up resistors, which are commonly used to "weakly" pull a signal line to a high state. Use this tag for discussing pull-ups.

A pull-up resistor is used to avoid having a pin "float" with undefined voltages, for example:

In this example the Arduino pin is kept at a `HIGH` level by the resistor. However if the switch is closed the pin becomes `LOW`.

Generally a high-value resistor (like, 10 k or more, possibly 100 k or even 1 M ohms) is used. When the switch is closed the 5 V line will be connected to Ground via the pull-up resistor, so you don't want too high a current to flow. In the above example the current would be:

``````I = V / R
I = 5 / 10000
I = 0.5 mA
``````

## Open-drain

Pull-up resistors are also used for "open-drain" designs, such as used in I2C. In such designs the data or clock lines are "pulled high" by a pull-up resistor, with multiple devices connected to the bus. When one of them wants to send a 0-bit they drive the line low, overriding the pull-up resistor. To send a 1-bit they let the pull-up resistor bring the line high again.

Doing it this way avoids having multiple devices "fighting" a bus, with some trying to drive it high, and some trying to drive it low.

In the case of I2C a resistor of 4.7 k is commonly used for SDA (serial data) and SCL (serial clock). Thus the I2C devices only have to be able to sink 10.6 mA (5 / 4700) which is usually within their design capabilities.

## Internal pull-up

The AVR Arduinos have built-in pull-up capabilities. This lets you design a pull-up into a circuit (such as a switch) without actually having to wire in a resistor.

The internal pull-up is specified for the Atmega328P (as used in the Uno) at being between 30 k and 50 k ohms.

You can activate the pull-up in code like this:

``````pinMode (3, INPUT_PULLUP);
``````