Why is a (pull down?) resistor needed when reading inputs on Arduino?

Discussion in 'Embedded Systems and Microcontrollers' started by HunterDX77M, Feb 28, 2016.

  1. HunterDX77M

    Thread Starter Active Member

    Sep 28, 2011
    I'm just starting out with Arduino and am building a simple circuit from one of the example pieces of code. In the attached schematic, I am trying to figure out why the 10K resistor is necessary. Is my understanding below correct?

    When the button is open, the input pin D2 would be connected through the 10K resistor to ground. Since D2 is designated in code as an input pin, there is no current flowing out of it, making the voltage drop across the 10K resistor 0 volts. So when the button is open, the D2 pin has a voltage of 0 volts (same as ground), so it is interpreted as a digital LOW signal.

    On the other hand, when the button is closed (i.e., pushed down), D2 is connected directly to 5 volts and so is a logical HIGH value. At this point there is voltage difference of 5 volts across the 10K resistor and 500 uA of current will flow down to the ground pin. In the state when the button is closed, is the resistor really needed? Why can't the pin D2 just be connected to 5V without any flow of current for it be read as a digital HIGH signal?

    Also is my terminology correct in calling this a pull down resistor?

  2. crutschow


    Mar 14, 2008
    You don't need the resistor to read the 5V.
    The resistor is needed to pull the input to 0V when the switch is open to read a digital low.
    If you let the input float, it will end up at some arbitrary voltage, not zero, due to the high impedance of CMOS inputs.

    For CMOS inputs, an open circuit is not the same as 0V, although that's a common fallacy.
    HunterDX77M likes this.
  3. HunterDX77M

    Thread Starter Active Member

    Sep 28, 2011
    Thanks, crutschow. That makes sense.
  4. dannyf

    Well-Known Member

    Sep 13, 2015

    it can be done that way, if the button is always closed.

    The pull-down resistor is there for when the button is NOT closed.

    Most mcus have pull-up resistors so a better arrangement is to connect the button to ground and turn on the pull-up resistors in the mcu.
    HunterDX77M likes this.
  5. TheButtonThief

    Active Member

    Feb 26, 2011
    +1 for this. Less components needed and less fussy.