In this tutorial, we will discuss how to use a pull-down resistor with a switch in Arduino.
Using Pull Down Resistor With a Switch in Arduino
If you want to use a switch with Arduino to get input, you have to use a pull-down resistor with the switch because if the pin is not connected to anything, it will read a random value from the environment, which can eighter be
HIGH. In the case of a switch, we want the pin to be
HIGH only if the switch is closed, and if it’s open, the pin should read
LOW. But if a pull-down resistor is not used with the switch, the pin will read a random value from the environment, which can eighter be
HIGH. A pull-down resistor connects the pin with the ground if the switch is open, so the pin will only read
LOW. To connect a pull-down resistor with a switch, check the below figure.
The value of the resistor should be between 1k to 100k. If you use a very low-value resistor, the current will flow to the ground when the switch is closed, and it can damage the Arduino. The
GND pins are present in Arduino, so you can use them with your switch and pull-down resistor. If the switch is closed, the pin will be directly connected to the
5V, and the pin will be in
HIGH state, and if the switch is open, the pin will be connected to the ground, and the pin will be in