Hey Everyone!
I have recently bought the Arduino Uno R3 and began experimenting with it, trying to learn some of the basics. Looking through some of the examples, I came across the "pushbutton" project which uses the button's state to turn the LED on/off accordingly. At first, I connected one leg of my pushbutton to GND (and the other to the digital Input pin on the Arduino) and I received the reverse of the result I was expecting; the button unpressed would turn the LED on and the button pressed would turn the LED off. After re-reading the project schematic, I realized I needed to connect this leg to the 5V power supply and the leg that was connected to the input pin also needed to be connected to a 10k resistor. When I didn't use the 10k resistor, the LED was never completely off and the pushbutton just affected whether it was slightly lit or completely lit. After making these changes, the button works as expected.
However, I am confused as to some of the thoery behind the circuity. If someone could please explain this, I would really appreciate it.
My questions are as follows:
- How does the current flow through the button and to the 10k resistor to GND when the switch is unpressed and the current is unable to pass?
- Why does the function of the button reverse when the leg is connected to GND?
- What purpose does the 10k resistor serve and why does it allow for the state to be either completely off or completely on?
Thanks!