Forgive my dumb question, but I'm just starting to mess around with Arduinos and building a circuit using them, and I keep coming across descriptions about using the digital inputs in conjunction with switches... and every description includes a pull-up or pull-down resistor connecting the digital pin to +5V (if the switch is connecting to Ground) or Ground (if the switch is connecting to +5V), but the result is the same -- the digital pin is sometimes connected to +5V, and sometimes connected to Ground, depending on whether you're depressing the switch or not.
So based upon my very limited understanding of how an electric circuit works (electricity flows in one direction, from positive to negative, or from +5V to Ground), how the heck can you connect anything to +5V sometimes and Ground sometimes? That doesn't make any sense! If the pin is an input, you have to send electricity to it, so you'd connect it to +5V, right? And if the pin is an output, you connect it to Ground, right? You don't sometimes connect the anode of an LED to +5V, and sometimes to Ground! You don't do that with ANYTHING -- except, apparently, the pins of an Arduino! All the tutorials I read show me that you can connect a digital input to +5V for a LOW reading, and Ground for a HIGH reading (or whatever), but nobody ever explains WHY -- they just assert that it's so, and it goes against everything I understand about how electricity works. I can't sometimes connect an LED to Ground, and sometimes connect it to 5V, and expect it to do something in both situations!
From this website: "Often it is useful to steer an input pin to a known state if no input is present. This can be done by adding a pullup resistor (to +5V), or a pulldown resistor (resistor to ground) on the input, with 10K being a common value. " "Steer"? "Known state"? What the heck is an input pin, that it can be "steered"? What is it doing? Electrical circuits don't get "steered", they flow in a circle. You can't suddenly grab one part of the circle and flip it upside down and have electrons flowing backwards for one arc of the circle!
I'm assuming there's something special about a digital input on an arduino -- the fact that it's a logic gate, or high-impedance, or something -- that makes it capable of being treated in this way... I know it's not Arduino-specific... does the circuit oscillate quickly between sending out electrons and receiving them, such that it is okay with being connected to either positive or negative? It's just so bizarre and counterintuitive...
Anyway, if anybody could shed some light on this question, it'd really be appreciated... I've tried looking online for an explanation, but I guess I'm not picking the right keywords, because I keep finding helpful diagrams about how to wire the circuit, but everybody except me seems to already understand the underyling theory of why and what is going on, 'cause nobody's talking...