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:
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?