I'm reading the book Getting Started with Arduino (Make:PROJECTS). I think most people here are familiar with this book.
I constructed the circuit as can be seen on page 43, typed the code and... it works. When I push the button, the led turns on, when I release the button the led goes off.
I do understand the code, but the circuit is not being explained. Why do I need to connect the Gnd to PIN7, to make this work, if there is no voltage applied to PIN7 it should be LOW or shouldn't?
If I disconnect all wires the led turns on just by coming near it with my fingers (not actually touching anything).
So I changed the code to turn off the led when PIN7 is HIGH and turn on the led when PIN7 is LOW. This works as expected when all wires are connected. I push the button the led turns off, I release the button the led turns on again.
Now the really strange thing, I disconnect all wires as I did before and would expect to turn off the led just by coming near it with my fingers... It stays on, just dims a little bit and starts flickering when I move my fingers away a little further.
Does anybody know what's going on and why it's behaving the way it does? ::) It's probably very logic but I need to understand it to be able to design my own connection layouts.