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?

Think about it...

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