This question already has an answer here:

I don't understand the books explanation for why a 10k resistor is needed for an open switch to write LOW to a digital pin. I thought no voltage is LOW anyway. Can someone explain in a little more detail why this resistor is needed.

enter image description here

enter image description here

marked as duplicate by Anonymous Penguin Jan 2 '15 at 17:13

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.