Circuit 3D

Pull-up resistor

A pull-up resistor connects an input to the supply so that it reads HIGH until a button or other device pulls it to ground; a pull-down resistor connects it to ground so that it reads LOW until something drives it high. Either one stops the input floating, and a 10 kΩ pull-up on 5 V draws only 5 ÷ 10,000 = 0.5 mA while the button is held.

I = V ÷ R

where V is the supply and R the resistor, so a 10 kΩ pull-up on 5 V draws 0.5 mA while pressed and almost nothing otherwise.

Values from about 4.7 kΩ to 47 kΩ suit most inputs, and many microcontrollers have an internal pull-up built in.

What is a pull-up resistor?

A pull-up resistor is a resistor from an input to the supply voltage, holding the input HIGH whenever nothing else is driving it.

Add a button from the input to ground and the input reads HIGH when released and LOW when pressed. In Figure 1, the lab’s push button and a 10 kΩ resistor do exactly that; swap them and the resistor becomes a pull-down.

Pull-up, released: the input draws almost no current, so the 10 kΩ resistor drops almost nothing and holds it at 5 V, HIGH, the supply.

Figure 1. The lab’s push button and a 10 kΩ resistor on 5 V, the green wire running to an input. As a pull-up the resistor goes to + and the button to −; as a pull-down, the other way round.

Why does an input need a pull-up or pull-down resistor?

An input needs a pull-up or pull-down resistor because, connected to nothing, it floats: it draws almost no current, so stray charge, mains hum or a nearby hand can push it between HIGH and LOW.

A floating input makes a button seem to press itself. A resistor to one rail gives the input a definite level whenever the button is open, while being large enough that the button can easily overrule it, as Figure 2 shows.

5 V 0 V reads HIGH reads LOW 100 ms

Floating: nothing holds the input, so stray charge and mains hum wander it between 0 and 5 V; in this sketch it swings between a clear HIGH and a clear LOW 9 times in 100 ms.

Figure 2. An illustration of a 5 V input with its button open: on its own it floats, and the shaded bands are where an Arduino Uno reads HIGH, above 3 V, or LOW, below 1.5 V.

What is the difference between a pull-up and a pull-down resistor?

A pull-up connects the input to the supply, so it reads HIGH until pulled LOW; a pull-down connects it to ground, so it reads LOW until driven HIGH.

Both work the same way, and the choice sets which level means pressed. With a pull-up the button is active low: LOW means pressed, which suits the internal pull-ups most chips provide. A pull-down reads more naturally, HIGH for pressed.

What value should a pull-up resistor be?

A pull-up resistor is usually about 10 kΩ, or anywhere from 4.7 kΩ to 47 kΩ: small enough to hold the input firmly, large enough not to waste current while the button is held.

Too small and it draws milliamps whenever the line is low. Too large and the input charges slowly through it, like an RC circuit, and leakage or noise can pull it off its level. Figure 3 weighs the trade.

wasteful balanced weak 1kΩ10kΩ100kΩ1MΩ

10 kΩ: pressed, it draws 500 µA, 2.5 mW; released, the input rises with τ = 10 kΩ × 20 pF = 200 ns, and a 1 µA leak would pull it down 10 mV: a good balance, and the usual choice.

Figure 3. A pull-up on 5 V, with about 20 pF of pin and wiring and an Arduino Uno’s worst-case 1 µA of input leakage. Smaller wastes current; larger is slower and weaker.

What is an internal pull-up resistor?

A pull-up built into a microcontroller’s pin, switched on in software, so a button needs only a wire to ground.

On an Arduino, internal pull-up resistors of about 20 to 50 kΩ turn on with pinMode(pin, INPUT_PULLUP). The button then reads LOW when pressed. Many chips also offer internal pull-downs; the Uno’s does not.

Why does I²C need pull-up resistors?

I²C needs pull-up resistors because every device can only pull its data and clock lines low or let them go; the pull-up resistors bring the lines back high.

That open-drain design lets the many devices on an I²C bus share two wires without fighting. The pull-ups set how fast each line rises against the bus’s capacitance, so long or fast buses need smaller ones; 4.7 kΩ is a common start.

How do you calculate a pull-up resistor?

To calculate a pull-up resistor’s current, use Ohm’s law for while it is pulled low, 5 V ÷ 10 kΩ = 0.5 mA, and use the bus’s rise time and capacitance to bound an I²C pull-up.

Example 1: a pull-up’s current

A 10 kΩ pull-up on 5 V holds a button’s input HIGH. How much current flows while the button is held?

Given
a 10 kΩ pull-up on 5 V, and a button to ground
Find
the current and power while the button is held
Solution
Pressed, the whole supply sits across the resistor: I = 5 V ÷ 10 kΩ = 500 µAP = V × I = 5 V × 500 µA = 2.5 mW
Answer
500 µA, 2.5 mW

Example 2: an I²C bus’s pull-ups

An I²C bus on 3.3 V runs at 100 kHz with 200 pF of capacitance on each line. What pull-up resistors can it use?

Given
an I²C bus on 3.3 V at 100 kHz, with 200 pF of capacitance
Find
the range of pull-up resistor that works
Solution
Smallest, so a device can pull the line to 0.4 V with 3 mA: (3.3 V − 0.4 V) ÷ 3 mA ≈ 967 ΩLargest, so it rises within 1000 ns: 1000 ns ÷ (0.8473 × 200 pF) ≈ 5.9 kΩA standard size in range: 5.6 kΩ
Answer
967 Ω to 5.9 kΩ, such as 5.6 kΩ

Summary

Key equations

  • I = V ÷ R while the button is held
  • τ = R × C how fast the input rises
  • Rmin = (V − 0.4 V) ÷ 3 mA I²C’s smallest
  • Rmax = tr ÷ (0.8473 × Cb) I²C’s largest

Key terms

Floating
An input connected to nothing.
Pull-up
A resistor from the input to the supply.
Pull-down
A resistor from the input to ground.
Active low
On when the signal is LOW.

Practice problems

  1. An input has a pull-up resistor and a button to ground. What does it read while the button is pressed?

  2. A 10 kΩ pull-up sits on 5 V. How much current flows while its button is held?

  3. What does an input with nothing connected to it do?

  4. About what is an Arduino Uno’s internal pull-up?

  5. Why do I²C lines need pull-up resistors?

FAQ

What does a pull-up resistor do?

It holds an input at the supply voltage, HIGH, until a button or device pulls it to ground, so the input never floats.

What is the difference between a pull-up and a pull-down resistor?

A pull-up ties the input to the supply, reading HIGH until pulled low; a pull-down ties it to ground, reading LOW until driven high.

What is a good pull-up resistor value?

10 kΩ is a common default for buttons on 3.3 V or 5 V. I²C buses often use 4.7 kΩ, or less for long or fast buses.

Do I need a pull-up resistor with INPUT_PULLUP?

No. INPUT_PULLUP switches on the microcontroller’s own pull-up, about 20 to 50 kΩ on an Arduino Uno; wire the button from the pin to ground.

Why does my button read random values?

Its input floats while the button is open. Add a pull-up or pull-down resistor, or use INPUT_PULLUP.

Can a pull-up resistor be too small?

Yes. It wastes current whenever the line is low, and a weak driver may not manage to pull the line below its LOW threshold.

Is a pull-up resistor a voltage divider?

Only once something draws current from the input. With the button open, almost no current flows, so the input simply sits at the supply.