3 Different Ways of Connecting a Push Button to Arduino

3 Different Ways of Connecting a Push Button to Arduino © GPL3+

Three different way of connecting a push button with an Arduino microcontroller.

  • 522 views
  • 3 comments
  • 4 respects

Components and supplies

Apps and online services

About this project

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.
#define button 5
boolean buttonState;
void setup()
{
 pinMode(button,INPUT_PULLUP);
 Serial.begin(9600);
}
void loop()
{
 buttonState = digitalRead(button);
 Serial.println(buttonState);
}

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.
#define button 5
boolean buttonState;
void setup() {
pinMode(button,INPUT);digitalWrite(button,LOW);
Serial.begin(9600);
}
void loop() {
buttonState = digitalRead(button);
Serial.println(buttonState);
}

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.
#define button 5
boolean buttonState;
void setup() {
pinMode(button,INPUT);
Serial.begin(9600);
}
void loop() {
 buttonState = digitalRead(button);
 Serial.println(buttonState);
}

Result

  • By default, the pin state will be LOW
  • When we press the push button the state will change to HIGH from LOW

Video

Support me by subscribing to my channel : http://bit.ly/2L7VLn3

Code

Push Button with Arduino using internal pull-up
Push button with Arduino using external pull up resistor
Push button with Arduino using pull down resistor

Schematics

Using internal pull up
Internal pullup ei7gc3hitl
Using external pull up
External pullup fzfhotra1t
Using external pull down
Pulldown r5liobpiiz

Comments

Similar projects you might like

Arduino - Use Reset Button Like a Push Button

by RoHa

  • 2,832 views
  • 0 comments
  • 12 respects

Fade Lights and Push Button

Project tutorial by Phuong Vo

  • 2,926 views
  • 2 comments
  • 9 respects

Push Button Combination Lock Using Arduino

Project tutorial by Asim Zulfiqar and High Voltages

  • 4,529 views
  • 9 comments
  • 20 respects

Arduino Button Troubleshooting

Project showcase by 3 developers

  • 646 views
  • 1 comment
  • 0 respects

Snap Circuits® - Push Button LED

Project tutorial by Daniel Porrey

  • 2,476 views
  • 0 comments
  • 10 respects

Snap Circuits® - Push Button Monitor

Project tutorial by Daniel Porrey

  • 1,198 views
  • 0 comments
  • 8 respects
Add projectSign up / Login