# Use of Resistor in PinWheel Exercise

I'm working on project 9 of the Arduino starter kit - the motorized pinwheel.

Here is the schematic:

(if img not showing: https://goo.gl/tqZmKD)

My question is, why is the 10k resistor needed after the switch? Why can't it just go straight to ground? The switch's output just connects to a digital pin, it doesn't care how much voltage there is, correct?

Thank you!

EDIT**: Additional help from the arduino forums: The resistor is needed so when the switch is closed you don't short the supply to ground. Switch open the resistor pulls the signal to ground and no current flows, when the switch is closed it forms a resistive divider with the 10k (switch contacts might have 0.01 to 0.1 ohms resistance or so), thus pulling the signal to Vcc, but with only 0.5mA flowing through the 10k resistor.

Replace the 10k with a wire and you'd simply overload the supply completely and perhaps weld the switch contacts shut. Arduino Forums

It's a pull-down resistor.

A pull-up or pull-down resistor is used the make sure that the input of a digital device is confined to strict logic levels, i.e +Vdd (positive, or HIGH) or GND (Ground, or LOW).

With the switch open and no resistor present, the Arduino pin is neither high nor low. It will probably read as low if you tried `digitalRead()`, but there's no guarantee. The probability of the pin being one or the other changes according to the layout of the PCB and other external factors; the pin is termed 'floating' because it could be at any voltage between Vdd and GND.

However, if you apply a pull-(somewhere) resistor you force the Arduino pin to one of either Vdd (up) or GND (down) until you press the switch, at which point the Arduino pin switches state.

If you removed the resistor and joined the switch directly to ground, what happens when the switch contacts close?

One side of the switch connected to Vdd.

The other side is connected to the Arduino and GND.

Close the switch, I dare you.

Vdd is now connected to GND

• Apologies - I didn't understand that. The switch controls whether or not voltage will continue to the green wire and thus, the digital input (in this case, pin 2). If switch is closed, voltage will continue to pin 2 and it will read HIGH. If switch is open, no voltage will pass through and the pin will read LOW. Is this not correct? And thank you for your time!
– ZAR
Jun 7 '15 at 19:39
• @ZAR: There is no situation of "no voltage" here; there is either Vdd or there is GND. Jun 7 '15 at 19:43
• Hmm, so how is there voltage if the switch is open and thus not completing the circuit? I thought there would only be current when the switch is pressed, closing the circuit... Clearly I am missing some fundamental knowledge ;)
– ZAR
Jun 7 '15 at 19:45
• @ZAR 'no voltage' and zero-volts ARE NOT THE SAME. No voltage is no connection to anything, Zero Volts is connection to ground. Jun 7 '15 at 19:53
• ...and a digital pin that is not connected to anything is called floating. Any floating digital input could be either high or low, and you can't guarantee which (unless you read it of course). Floating digital inputs are thus highly inadvised. The same doesn't apply for unused pins - they can be left unconnected. Jun 7 '15 at 19:58