10 in stock
A push-button/tactile switch is a switch which controls the open-ness or closed-ness of an electric circuit.
Let’s say you have an evive with one digital pin configured as an input. If there is nothing connected to the pin and your program reads the state of the pin, will it be high (pulled to VCC) or low (pulled to ground)? It is difficult to tell. This phenomenon is referred to as floating. To avoid this unknown state, a pull-up or a pull-down resistor ensures that the pin is in either a high or low state, while also using a low amount of current. While using switches you use pull-up or pull-down resistors. With a pull-up resistor, the input pin will read a high state when the button is not pressed (since right now, it is connected to VCC). In other words, a small amount of current is flowing between VCC and the input pin (not to ground), thus the input pin reads close to VCC. When the button is pressed, it connects the input pin directly to ground. The current flows through the resistor to ground (remember, current chooses the path of minimum resistance) , thus the input pin reads a low state.
Hence when the switch is not pressed, you get a HIGH reading on the digital pin and when the switch is pressed you get a LOW reading, when you are using pull-up resistor. Generally you use a resistor of 10k ohm. If you are using a pull-down configuration, the result is exactly opposite.