Go Down

Topic: About the position of Resistors in project 1 and 2 (Read 5 times) previous topic - next topic


I'm just starting with Arduino and have a quick question on project # 2 (Spaceship Interface): Why do we need to add a 10k-ohm resistor from ground to the switch pin?  Is this to protect the switch or is the power flowing from the switch through the resistor then onto the other resistors? I guess I'm just trying to understand the flow of the electricity and how it travels through each resistor.


Jan 03, 2014, 06:53 pm Last Edit: Jan 03, 2014, 07:12 pm by JimboZA Reason: 1
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.)


Roy from ITCrowd: Have you tried turning it off an on again?
I'm on LinkedIn: http://www.linkedin.com/in/jimbrownza

Go Up