Use of Resistor in PinWheel Exercise


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

Here is the schematic:

(if img not showing:

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!

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.

See this for the two ways of fitting a switch.