What are pull-up and pull down resistors? 

 January 11, 2018

By  Peter

A question I get asked frequently by people new to circuit design is about pull-up and pull down resistors.

What is the purpose of a pull-up or pull down resistor, and how does it work?

I’ll try to answer this question here as simply as I can. When I think about this, it really is simple.

Here it goes:

Imagine that you have a switch. One pin is connected to a 5V source, and the other to a logic circuit. A logic circuit is a component that expects certain values only at its pins, usually HIGH or LOW, and it doesn’t really work well with anything else. An example could be an ATMega micro-controller, like the one you find in an Arduino board.

Schematically, you would have something like this:

This looks fine, the switch is closed and the input of the logic circuit is directly connected to Vin, so it is HIGH. No problem! What if we open the switch?

Well, now there is a problem. The input of the logic circuit is not connected to anything with a specific value, it’s just hanging there. Another term people often use for this kind of situation is “floating”.

Let’s repeat: the problem here is that the input of the logic circuit is not connected to a source of defined value, and logic circuits really don’t like this!

So how do we fix it? Have a look at the next schematic:

We fix this by using a large resistor (say, 10kΩ or larger) to connect the input of the logic circuit to ground. When the switch is open, instead of the input to be floating to an uncertain value, it becomes grounded, therefore LOW, through the resistor.

What if the switch closes again? Then, we’ll have this:

Because the resistor is large, current from Vin will find it much easier to flow through the logic circuit rather then to ground via the resistor. Because the connection between Vin and the logic circuit input has negligible resistance, the Vin’s HIGH value will be transferred to the input of the logic circuit.

To recap, by attaching a pull-down resistor to our circuit, we ensure that the logic circuit’s input will always have a defined value, and will be happy.

You could inverse the circuit and connect the resistor to Vin instead of ground. Now, this resistor would be called “pull-up”, because it would be pulling the input of the logic circuit to Vin (HIGH) when the switch was open.

A pull-up resistor schematic would look like this:

I have just swapped the positive voltage (differential) to the top of the diagram and the ground to the bottom. When the switch is open, the input of the logic circuit is connected to Vin via the large resistance, so the voltage there is almost Vin. There will be a very small current flowing so there will also be a very small drop in voltage from Vin to the input of the logic circuit, but this is small enough to be able to accept an approximate value at the logic circuit as Vin, which is HIGH.

Peter


Peter Dalmaris is an educator, electrical engineer, electronics hobbyist, and Maker. Creator of online video courses on DIY electronics and author of three technical books, and has recently released his book Maker Education Revolution.   As a Chief Tech Explorer since 2013 at Tech Explorations, the company he founded in Sydney, Australia, Peter’s mission is to explore technology and help educate the world.  Tech Explorations offers educational courses and Bootcamps for electronics hobbyists, STEM students and STEM teachers. A life-long learner, Peter’s core skill is in explaining difficult concepts through video and text. With over 15 years of tertiary teaching experience, Peter has developed a simple yet comprehensive style in teaching that students from all around the world appreciate.  His passion for technology and in particular for the world of DIY open source hardware has been a dominant driver that has guided his personal development and his work through Tech Explorations. Peter’s current online courses have helped over 60,000 people from around the world to be better Makers. 

Peter Dalmaris

  • Hi Sir, I have found one correction in your lecture. In the course, “Arduino Step by Step: Getting Started”, Lesson 9 – Using digital input pins @8:11, there one correction might be required.

    You are saying when the SWITCH is closed, current flows from “pin ~5” to GND

    But “pin ~5” is reading input right? So obviously current has to flow into it.

    So the possible explanation could be,

    current starts from 5V pin on left –> large resistor –> switch –> then goes directly to GND instead of going to “pin ~5” as per least resistance principle.

    • Hi Sagar,

      The D5 pin, or any other pin when used as an input, reads a state from the component that is connected to it. In our case, this is a button.
      The state detection is done by determining the “result” of the current path. If the current path ends in 5V, meaning that the button is not pressed, the result is HIGH. In the opposite case, if the button is pressed, then the end of the path is the GND pin because the large resistor on the other path makes current to avoid it. In this case, the result is LOW.

      In both cases, current flows from the digital pin to the path and the result is determined by the end of the path, either 5V or GND pins. This current is not used to power something, it is used in order to detect the state of the input component. Don’t get confused about the current flow when a pin is used as input, the important point is to determine the resulting state that the Arduino will understand.

      Your possible explanation:
      “current starts from 5V pin on left –> large resistor –> switch –> then goes directly to GND instead of going to “pin ~5” as per least resistance principle.”
      is not correct because when the button is pressed and therefore the switch is closed, current chooses the path with the less resistance and that is not the path that leads to 5V.

      Hope this helps.

      Best regards,
      Vagelis

  • {"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

    Subscribe to our newsletter now!

    >