Purpose of a Pull-Down resistor [duplicate]

Being just a beginner I'm really getting confused of pull-down resistors. Please have a look at the diagram below. Here there is a 10k pull down resistor is connected to ground and the pin 2 of arduino. Whats really the purpose?

Is it really to avoid shorting between the 5v and ground?? So if there is a LED (load) in the circuit when the button is pressed do we really need the pull-down resistor?

Also if the button is connected to an external source (5v battery) do we need a pull-down resistor in that case as well??

One more question, if I have 5 buttons to pin 1-5, So do we just need a common pull down resistor say 100k for the 5 buttons?

• – Huisman Jan 6 at 11:25
• There are about half-dozen questions on EE.SE about the purpose of a pull-up or -down for a button. – Nick Alexeev Jan 6 at 21:01

Is it really to avoid shorting between the 5v and ground?? So if there is a LED (load) in the circuit when the button is pressed do we really need the pull-down resistor?

A pull-down or pull-up resistor is used to give a floating pin a defined potential. Sometimes it's also used as driving source for serial communications as usually controller pins are better in sinking than in sourcing.

Also if the button is connected to an external source (5v battery) do we need a pull-down resistor in that case as well??

The type of source doesn't matter.

One more question, if I have 5 buttons to pin 1-5, So do we just need a common pull down resistor say 100k for the 5 buttons?

You cannot have a common pull-down because that would mean that you have all input pins connected together, just draw the corresponding schematic and you'll see the problem.

• THanks a lot friend.. that make sense... Sorry I didnt understand clearly the answer for the first question... – Sandeep Thomas Jan 6 at 10:28
• @SandeepThomas The key fallacy beginners often fall for (in my experience at least) is that a pin not connected to anything is at 0V. Not connected to anything, so can't have any voltage on it, right? For various reasons, that's not true - if it's not connected to anything, it's actually at an undefined potential, which clearly causes issues if you're expecting it to be at a certain voltage. The pulldown (or pullup) resistor keeps the pin in a known state, while also having a high enough resistance so as not to cause excessive current draw. – berry120 Jan 6 at 18:32
• @berry120: A better way of explaining things may be to view such a pin as an electric field detector. If one builds a high-impedance voltage follower and attaches the input to e.g. a piece of foil, putting one's hand near the foil will often cause the detected voltage to change. A pin which is neither pulled up nor pulled down will be influenced by such fields, in ways that are likely to be neither useful nor predictable. – supercat Jan 6 at 20:27

A pull down resistor is not to prevent a short circuit. Your diagram is quite minimal, but a pull down (or up) resistor is used in the following situations:

1. You connect something to an input pin. When the switch is open (or no closed circuit,) the input pin will get values between 0 (GND) and e.g. 5 (VCC) volts and anything in between. With a pull down or pull up resistor, you can force it the input pin to be 0 V or 5 V. Mostly when you use a switch, you want to have a pull down resistor, so when the switch is open, the input pin gets a value of 0 V and not a 'floating' value. Without a pull down resistor, the input pin is called a so called floating pin.
2. During the startup of the Arduino the pins are not initialized, and an output is not defined. To be sure it is 0 or 5 V, you can use a pull down or pull up resistor.