Working through the Arduino starter kit, and I have a circuit arranged with standard pull down resistor, but I'm stuck on a detail. I see how when the switch is open, any stray current will want to run to ground (pulling down the pin voltage to 0) since the resistor is 10KOhm and the digital pin input appears to be 10MOhm. But when the switch is closed, why wouldn't the current want to continue running to ground? I would expect pin voltage to stay at 0. After all, the pin hasn't changed it's resistance? It's still much higher.
Clearly, I'm misunderstanding something, but I'm not sure what.
The resistor is sufficiently high enough to not allow more current than the supply can provide. The digital pin is a HIGH IMPEDANCE input, which does not use much current either. The resistor is there to make sure that pin drains to ground potential quickly when power is removed (switch). Without the pulldown, the pin can be left "floating", which means it can be anywhere from 0-Vcc. That can lead to unpredictable outcomes
It sounds like you are missing a couple of fundamental concepts.
skj23:
any stray current will want to run to ground (pulling down the pin voltage to 0) since the resistor is 10KOhm and the digital pin input appears to be 10MOhm. But when the switch is closed, why wouldn't the current want to continue running to ground? I would expect pin voltage to stay at 0. After all, the pin hasn't changed it's resistance?
It’s not really about stray currents or the difference between the two resistances; it is the fact that, without the 10k resistor, the digital input would be “floating” because there is no direct connection to a known voltage level. When the switch is open, there is no current and as Ohm’s Law tells us, there is no voltage drop across a resistance with no current. That means the voltage on both the top and bottom of the resistor is equal to ground and so the input sees 0V.
When the switch closes, you’re totally correct that the current wants to run to ground but the resistor is in the way and limits current flow, producing a voltage drop. That voltage drop is what the input pin is actually measuring. Although some current does actually pass into the input, it is so miniscule compared to what’s going through the resistor, you can call it 0 and still be correct. So the input pin is measuring the voltage across the resistor which, for all intents and purposes, is equal to Vin.
I hope that response wasn’t too basic or like telling you to suck eggs.