Button Use with Arduino

Hello in this series of articles, we will look at the use of buttons, although we have written with Arduino in the title; circuits, microprocessors, or even anywhere in the same way. The pull-up and pull-down activity, which is named by the resistance binding method, is carried out with resistance of 10k ohm. In the use of the button where resistance is not used, after pressing the button, even if the remaining energy button is not pressed, this energy is dampened using resistance, in addition to these two methods we will process Arduino's internal pull-up function. 1253

Pull Down Resistance

Pressing the button shorts the entrance of the Arduino with the voltage source. When you take your hand off the button, there's still energy on the line. This energy causes Arduino to pretend to push the button, even if the button is not pressed. For the destruction of this energy, the line is usually connected to the soil with a resistance of 10K ohm. This resistance is called pull down resistance.

Pull-Up Resistance

In cases where the button is not pressed, the arduino's input pin is at the level of 5 volts. When the button is pressed, the current reaches directly into the soil instead of arduino's inlet pin. Thus, the pull-down resistance system works in the opposite way. Arduino sees 0 when the button is pressed and 1 when the button is not pressed. Our aim to use pull-up resistance is to prevent the soil and supply line from being short-circuited directly when the button is pressed. Pull-down resistance, as well as pull-up resistors, usually have 10K ohm.

Arduino Built-in Pull-Up Resistance

To use this function we need to use INPUT_PULLUP in the pinMode() function, arduino and AVR chips also have pull-up resistance between 20k ohm and 50k ohm, so we can do the same without using resistance. pull down pull up

Arduino Internal Pull-Up Code

const int buttonpin = 4;

const int ledPin = 8;

int butt butt = 0;

void setup()


pinMode(ledPin, OUTPUT);

pinMode(buttonPin, INPUT_PULLUP);


void loop()


butdurum = digitalRead(buttonpin); button press control

if (butdurum == LOW) //button is pressed


digitalWrite(ledPin, HIGH); LED ON

delay(3000); Wait 3 seconds

digitalWrite(ledPin, LOW); LED OFF