Simple Button Digital Input using Arduino

Today we learn the simple simple Button Digital Input using Arduino it is very easy.

The Arduino has Digital I/O PINs. Which “I/O” is Input and Output We used the output of Arduino to display the LEDs.
Today we need to use the switches as digital input pins to get a various electrical signals to control the operation of the circuit as well.

What is Digital?
Digital is a kind of electrical signal. Which has work of only two states are:
– HIGH or ON or “1”
– LOW or OFF or “0”
We bring this digital Go to the many benefits and high accuracy.

What is the digital Input?

Digital Pins of Arduino can read 2 status are “HIGH” and “LOW” depend on that Pin has current or not.

Pull-up , Pull-Down
The Button switch to Input Pin of Arduino. We need to connect the resistor to exact status of the inputs. We use 2 form circuits

• Pull-Up: the Input will be connected with a resistor that call “Pull-UP Resistor” to a Vin we will have the status “HIGH” all the time, until you press button to LOW or ground, the Arduino will read “LOW” or we call “Active Low”

• Pull-Down: the Input will be connected with a resistor that call “Pull-Down Resistor” to a Ground we will have the status “LOW” all the time, until you press button to Vin or HIGH, the Arduino will read “HIGH” or we call “Active High”

We will see that 2 circuits have the operation reversed. Depending on what is selected.

Figure 1 Pull-up and Pull-Down Circuits

This resistors Pull-Up / Down Resistor used the 5K – 20K. We use 10K

Start to build the Button to control LED

We will use Input Pin of Arduino to receive the button status, then control LED display on Output Pin 13. By use the Pull-Down to apply LED grow up when we press the button only.


Parts will you needs
• Arduino UNO R3
• Normally open pushbutton
• one LED
• 10K resistor
• 470 ohms resistor
• jumper wires
• Breadboard

Simple Button Digital Input using Arduino_bb
Step 2 connect the parts as circuit Figure 2 The circuit connection

This circuit use Pull-Down by connect the Button to 5V power supply and 10K resistors to ground. And We use Digital PIN 3 as Input. Next, the Output is Digital PIN 13 connected to LED by 470 ? resistor to limit current.

Simple button digital input using arduino
Figure 3 Simple Button Digital Input using Arduino

Let’s test it

We type the code on IDE below

Figure 4 the Simple Button Digital Input code with delay

int buttonPin = 3;  // the number of the pushbutton pin
int ledPin = 13;   // the number of the LED pin
int buttonState = 0; // variable for reading the pushbutton status
int delay1 = 10000;

void setup() {
  pinMode(ledPin, OUTPUT);  // initialize the LED pin as an output:
  pinMode(buttonPin, INPUT);  // initialize the pushbutton pin as an input:

void loop() {
  buttonState = digitalRead(buttonPin);   // read the state of the pushbutton value:
  // check if the pushbutton is pressed.
  // if it is, the buttonState is HIGH:

  if (buttonState == HIGH) {
    digitalWrite(ledPin, HIGH);// turn LED on:
  else {
    digitalWrite(ledPin, LOW);// turn LED off:

We test it as Video, first type code on IDE without “delay” command. And upload When we press the button LED will glow as we press. Then, we put code delay. The LED will delayed time turn ON about 10S.

Now we use the button or switch as digital input. It is easy

Sharing is caring!

JLCPCB - Only $2 for PCB Protytpe(Any Color)

With 600,000+ Customers Worldwide, 10,000+ PCB Orders Per Day

Up to $20 shipping discount on first order now:

Related Posts


I always try to make Electronics Learning Easy.

Close Menu