Below is a simple circuit involving an Arduino, a push-button, and an LED. However, I don't quite understand what the purpose of the resistor is. Wouldn't the circuit function without it?

Source:"MAKE: Getting started with Arduino"

Note: Since this question is concerning the behaviour of the circuit rather than the functioning of the Arduino, I've posted this here instead of the Arduino stack exchange.

  • 5
    \$\begingroup\$ Very nice drawing, but we prefer schematics as they are easier/faster to read. There is a built in editor on the spaces where you can write your question. \$\endgroup\$ – Wesley Lee Apr 22 '18 at 18:57

It's a pull down resistor, its purpose is to set the voltage of the Arduino input to 0 V when the button is open. It just set a default voltage value to the connected node.

But, why such a resistor in needed? Well, when the button is open, the voltage is not totally equals to zero due to antenna effect or surrounding component. It is then possible that the Arduino input is trigger for no reason.

Note that the value of pull up or pull down resistors use to be around 10k - 100k. If the value is to low, it's going to draw to much current when the button is close. If the value is too high, the resistor will behave as an open circuit, making the pull down resistor useless.

As it is widely used in electronics, I recommend you to read some more about this concept.

  • 2
    \$\begingroup\$ Simply call it "floating" :) \$\endgroup\$ – Long Pham Apr 22 '18 at 15:02
  • 3
    \$\begingroup\$ Even absent crosstalk, there's no reason that the voltage would change to zero when the switch opens. The intrinsic capacitance in the GPIO pin would tend to hold the voltage, and that will slowly drift due to non-zero leakage current. Depending on the direction of that current, it could drift down toward 0V but could also drift upwards. \$\endgroup\$ – Ben Voigt Apr 22 '18 at 17:22

This looks like a pull-down resistor.

a pull-[down] resistor is a resistor used to ensure a known state for a signal.

[They] are used in electronic logic circuits to ensure that inputs to the [microcontroller] settle at expected logic levels if external devices are disconnected or high-impedance. 'Just because you have nothing at all connected to an input pin doesn't mean it is a logical zero.'

[D]igital logic circuits have three logic states: high, low and floating (or high impedance). The high-impedance state occurs when the pin is not pulled to a high or low logic level, but is left “floating” instead. [...] a microcontroller might unpredictably interpret the input value as either a logical high or logical low. Pull-[down] resistors are used to solve the dilemma for the microcontroller by pulling the value to a logical [low] state

By the way, as your LED seems to lack a current limiting resistor, it will likely burn out pretty quickly, unless it has some integrated current limiting circuitry that is not visible in the drawing.

  • \$\begingroup\$ Good, complementary and helpful answer, as you include actual links instead of just lecturing "...I recommend you to read some more about this concept." \$\endgroup\$ – uhoh Apr 22 '18 at 15:39
  • \$\begingroup\$ @uhoh Except link-only answers are not so valuable on SE since links often die or change. \$\endgroup\$ – Todd Wilcox Apr 23 '18 at 16:41
  • 1
    \$\begingroup\$ In my defense, I don't think anyone expects Wikipedia to go away anytime soon. But yes, it did enter my mind. Would it help if I quoted some of the key points from the links? \$\endgroup\$ – Dampmaskin Apr 23 '18 at 17:00
  • \$\begingroup\$ @Dampmaskin that's the ideal answer at least, a nice concise, clear explanation together with helpful supporting links. \$\endgroup\$ – uhoh Apr 23 '18 at 17:10
  • \$\begingroup\$ I have now inserted quotes/paraphasings from the sources, to increase its long term usefulness. \$\endgroup\$ – Dampmaskin Apr 23 '18 at 17:40

People tend to think that undefined is equal to zero. Compare it to something in a store that has no price label: customers will joke it is for free ($ 0.00), but it is not: the price is unknown.

It is the same with voltages/potentials. If the button is not pressed (not conducting) the potential on input 7 is not defined. It is tempting to say it will be 0V, but there is no reason for it to be. By connecting it to 0V (gnd) trough a resistor it suddenly is defined: there is no current (where would the energy come from), so the voltage over the resistor must be 0V as well. 0+0=0V.

If we replace the resistor with a short circuit the voltage would be zero as well, as long as the button is not pressed (not conducting). But what would happen once you press the button? The left side of the button is at 5V, the right side at 0V (gnd). The result is a short cut: the maximum current will flow from 5V to the gnd and you still do not have a defined voltage at input 7.

  • 1
    \$\begingroup\$ You say "shortcut". Did you mean "short circuit"? \$\endgroup\$ – longneck Apr 23 '18 at 14:26
  • \$\begingroup\$ This is the clearest correct answer. \$\endgroup\$ – Reversed Engineer Apr 23 '18 at 16:38

Pull-down resistor in a digital circuit can be seen in the figure. A pushbutton switch is connected between the supply voltage and a microcontroller pin. In such a circuit, when the switch is closed, the micro-controller input is at a logical high value, but when the switch is open, the pull-down resistor pulls the input voltage down to ground (logical zero value), preventing an undefined state at the input. The pull-down resistor must have a larger resistance than the impedance of the logic circuit, or else it might be able to pull the voltage down by too much and the input voltage at the pin would remain at a constant logical low value – regardless of the switch position.

Taken from below site Read more http://www.resistorguide.com/pull-up-resistor_pull-down-resistor/

  • 1
    \$\begingroup\$ The OP is asking about the pull-down resistor connected to the switch. He hasn't shown (or asked about) the required current-limiting resistor in series with the LED. \$\endgroup\$ – Peter Bennett Apr 22 '18 at 18:05

Not the answer you're looking for? Browse other questions tagged or ask your own question.