0% found this document useful (0 votes)
2 views7 pages

Lab-2 - Arduino With Simple Button Interfacing

This lab report details an experiment on interfacing a push button with an Arduino UNO to control an LED. The objective is to understand digital input operations, where pressing the button sends a HIGH signal to turn the LED ON and releasing it sends a LOW signal to turn it OFF. The report includes required components, circuit diagrams, program code, observations, and concludes that the interfacing was successful.

Uploaded by

Nayeem Sarkar
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views7 pages

Lab-2 - Arduino With Simple Button Interfacing

This lab report details an experiment on interfacing a push button with an Arduino UNO to control an LED. The objective is to understand digital input operations, where pressing the button sends a HIGH signal to turn the LED ON and releasing it sends a LOW signal to turn it OFF. The report includes required components, circuit diagrams, program code, observations, and concludes that the interfacing was successful.

Uploaded by

Nayeem Sarkar
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Lab Report: 02

Title: Arduino with simple Button Interfacing


Course title: Internet of Things Laboratory
Course code: CSE-460
4 Year 2nd Semester Examination 2024
th

Submission Date: 22nd February, 2026

Submitted to-

Dr. Md. Ezharul Islam


Professor
Department of Computer Science and Engineering
Jahangirnagar University

Samsun Nahar Khandakar


Assistant Professor
Department of Computer Science and Engineering
Jahangirnagar University

Sl Class Roll Exam Roll Name

01 388 210908 MD Mursalin Sarkar

02 389 210909 Md Sourav Ahmed

03 2116 202164 Anjuman Ekra


Lab–2: Arduino with Simple Button Interfacing

1. Objective

● To understand how a push button works as a digital input device.

● To interface a push button with an Arduino board.

● To control an LED using button input.

● To learn basic digital input/output operations using Arduino IDE.

2. Components Required

Sl. No Component Name Quantity

1 Arduino UNO Board 1

2 Push Button Switch 1

3 LED 1

4 220Ω Resistor 1

5 Breadboard 1
6 Connecting Wires As needed

7 USB Cable 1

3. Circuit Diagram

Connection Summary:

● Button Pin → Digital Pin 2

● LED Anode (+) → Digital Pin 12

● LED Cathode (–) → 220Ω Resistor → GND

● One side of Button → 5V

● Other side of Button → Pin 2

4. Description

In this experiment, a push button is used as a digital input device to control


an LED.
When the button is pressed, Arduino reads a HIGH signal from the input pin
and turns the LED ON.
When the button is released, the input becomes LOW and the LED turns
OFF.

This demonstrates the use of Arduino’s digital input and output pins in an
embedded system.
5. Theory

A push button is a momentary switch that allows current to pass only when it
is pressed.

Arduino reads digital signals in two states:

● HIGH (1) → Voltage present (5V)

● LOW (0) → No voltage (0V)

The button acts as an input device and sends HIGH or LOW signals to
Arduino.
Arduino processes this input using the digitalRead() function.

Based on the input signal:

● If input = HIGH → LED ON

● If input = LOW → LED OFF

The LED is controlled using the digitalWrite() function through an output


pin.
6. Algorithm

1. Start

2. Define LED pin as OUTPUT

3. Define Button pin as INPUT

4. Read the button state

5. If button is pressed
Turn ON LED

6. Else
Turn OFF LED

7. Repeat from step 4

7. Program Code

const int buttonPin = 2;


const int ledPin = 12;
int buttonState = 0;

void setup() {
pinMode(ledPin, OUTPUT);
pinMode(buttonPin, INPUT);
}

void loop() {
buttonState = digitalRead(buttonPin);

if (buttonState == HIGH) {
digitalWrite(ledPin, HIGH);
}
else {
digitalWrite(ledPin, LOW);
}
}

8. Observation
Button State LED State
Pressed ON
Released OFF

9. Result

The LED successfully turned ON when the push button was pressed and
turned OFF when the button was released.
This confirms correct interfacing of the push button with Arduino.

10. Conclusion

The experiment demonstrates successful interfacing of a push button with


Arduino UNO to control an LED.
It helps in understanding digital input/output operations and basic hardware
interfacing using Arduino IDE.

You might also like