3 Different way of connecting a push button to Arduino
INTRODUCTION
In this chapter, we are going to learn the three different way of connecting a push button with Arduino microcontroller.
3 Ways
- Internal pull-up resistor
- External pull-up resistor
- External pull-down resistor
Internal pull-up resistor
- Connect the push button with Arduino as shown in the circut ie,
- Connect one terminal of the push button to any digital pin of Arduino in my case I'm using digital pin D5
- Then connect the other terminal of the push button to the ground of Arduino.
- Now upload the below code.
Code
Result
- By default, the pin state will be HIGH.
- When we press the push button the pin state will change to LOW.
External pull-up resistor
- Connect one of the terminal of the push button to any digital pin of Arduino, in my case I have used digital pin 5.
- Connect the other terminal of the push button to the ground of Arduino.
- Then connect a resistor of value 10 Kohms from the digital pin which you have connected the push button to the 5v of Arduino, in my case I have connected the resistor form digital pin 5 to 5v.
- Now upload the below program.
Code
Result
- By default, the pin state will be HIGH
- When I press the push button the state will change to LOW.
External pull-down resistor
- Connect one of the terminal of the push button to any digital pin of Arduino, in my case I have used digital pin 5.
- Then connect the other terminal to the 5v of Arduino.
- Then connect a resistor of value 10 Kohms from the digital pin which you have connected the push button to the ground of Arduino, in my case I have connected the resistor form digital pin 5 to ground.
- Now upload the below code.
Code
Result
- By default, the pin state will be LOW
- When we press the push button the state will change to HIGH from LOW
Video
3 Different way of connecting a push button to Arduino
Reviewed by Abu Yazid
on
May 11, 2019
Rating: