arduino push button without resistor

Arduino button without resistor pull up or pull down

Buttons are everywhere, many of our projects using button to interact with users. Many tutorials told us to use resistor as pull up or pull down for button. And maybe you have question and that’s why you are here. Does resistor really needed? Can we just skip the resistor and using only button?. Hmmmm fortunately the answer is yes! The arduino has internal pull up resistor that you can use it so you don’t need resistor to use your button.

So, how do we do that? Here’s the schematic example :

arduino push button without resistor
arduino push button without resistor

Or this

arduino push button without pull up
arduino push button without pull up

And this is the code:

int button = 2;

void setup() {
  // put your setup code here, to run once:
  pinMode(button, INPUT);
  digitalWrite(button, HIGH); //activate arduino internal pull up
  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  if (digitalRead(button)==LOW){
    Serial.println("Button is pressed");
  }
  delay(500);
}

 

How is it? Do you love it? Comment below.

One Reply to “Arduino button without resistor pull up or pull down”

  1. Good day. Thank you for the tutorial. I tried it on Arduino Uno and everything worked flawlessly. However, I am facing issues when trying to implement it on the ESP8266 board. Could you please guide me on how to modify the code accordingly or is it even possible?
    Yours sincerely,
    Ruslan.

Leave a Reply

Your email address will not be published. Required fields are marked *