Skip to main content

How to connect a Push Button with Digital Input Pull-Up resistor

What is Digital Input Pull-Up resistor?

In Arduino, a Digital Input Pull-Up Resistor is an internal resistor that you can enable on digital input pins to ensure a known default voltage level (HIGH) when the pin is not actively connected to anything (i.e. it’s “floating”).

We have another tutorial showing how to use a button the normal way.

Advantage of using a button this way

  1. Fewer External Components

    • No need for an external resistor—the internal pull-up does the job.
    • Makes circuits simpler and saves space, especially on a breadboard.
  2. Stable Default State (HIGH)

    • Ensures the input pin has a known state (HIGH) when the button is not pressed.
    • Prevents floating inputs, which can cause random or noisy readings.
  3. Simpler Wiring

    • You only need to wire the button between the pin and GND.
    • Ground is often easier to route in a circuit than Vcc (especially with many buttons).

Wiring

  • one pin to GND
  • one pin to 2

Getting started

void setup() {
  pinMode(2, INPUT_PULLUP); // Internal pull-up enabled
  Serial.begin(9600);
}

void loop() {
  int buttonState = digitalRead(2);
  Serial.println(buttonState); // Reads HIGH when not pressed, LOW when pressed (to GND)
  delay(100);
}