Electronic – arduino – Understanding pull down resistor current flow

arduinopulldown

I'm working on an introduction to Arduino and circuits course and I've run into a stumbling block.

Everything works the way the course says that it should – I just don't understand WHY it works.

Here's the schematic:

Arduino and breadboard with LED and dip switch

The program is easy to understand. When digital input 2 receives input it lights the LED. The whole path with the LED makes sense to me, no need to discuss it. It's the path with the red wire and green wire going into the DIP switch.

My understanding is that the DIP switch is connected to both the digital input and the resistor and the resistor provides a path to ground for any stray voltage that gets induced on the wire by the environment.

What's confusing me is – isn't the digital input also a path to ground? If not, how does the circuit ever get closed? If there is stray voltage the resistor is providing a path to ground, but if the switch is closed then suddenly the digital input is the best path to ground?

When the switch is closed, the 5 volts can either go to the digital input or through the resistor and the resistor path has more impedance and so the 5V goes into the digital input. When the switch is open, why would any stray voltage not take the same path that the 5V takes?

Best Answer

No current flows in or out of the input pin.

It has no path for current to flow, whether the input pin is connected to 5V or 0V (ground).

So no current flows when resistor keeps the voltage at 0V.

When DIP is set ON, only current from 5V flows via resistor to ground.

That is how ideal input pins work. In real life there could be some leakage currents flowing in the order 1 microamps, which for simple beginner circuits can be ignored.