About the position of Resistors in project 1 and 2

JimboZA:
John I don't have a starter kit, so I don't have the circuit in front of me, but....

The resistor you mention is a so-called "pull-down" since it pulls one side down to 0v. (If you stick it on the other side, to 5v, then no surprises it's a pull-up.

In a digital world, pins need to be at either a high or a low state, 1 or 0, 5v or 0v. If a pin isn't connected to anything, then it's voltage can literally be anything, due to interference from passing asteroids or who knows what. So, since when we read our pin we need to be able to rely on it being one way or the other, not some random "floating" value in between, we pull it to one or other side with a resistor. So if you read the switch when the button is not pushed, it will read 0v reliably in your case due to pull-down resistor.

Then when you hit the switch, the wire to 5v from the switch hooks the pin to 5v which is what you want when the switch is pushed.

Lastly, why use a resistor at all, and not just a wire? Well look at your circuit and you'll see that when the switch is pushed, there is a path from 5v thru the switch thru the resistor to 0v. Without the resistor, that path would be a dead-short and BOOM.

)EDIT- also with no resistor, both the 5 an 0 sides of the switch will be competing and the switch in the middle of the divider with 0 resistance on both sides would then get 2.5v, but the short would have melted something first. But anyhoo, with the resistor on one side, the other side "wins" and the pin gets almost all the 5v.)

HTH?

Jim

I assume that in this case we could use any resistor.. right? Or does it have to be a 10 kOhm resistor?