Skip to content

A simple digital input-output project where an LED is controlled by a push button. When the button is pressed, the LED turns **ON**; when released, it turns **OFF** — the perfect beginner exercise to understand digital logic and I/O pins on Arduino.

Notifications You must be signed in to change notification settings

asathiskumar98-byte/Button-Controlled-LED-using-Arduino-UNO

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

🔘 Button Controlled LED using Arduino UNO

A simple digital input-output project where an LED is controlled by a push button.
When the button is pressed, the LED turns ON; when released, it turns OFF — the perfect beginner exercise to understand digital logic and I/O pins on Arduino.


🧠 Overview

This project demonstrates how to:

  • Read a digital input (button state)
  • Control a digital output (LED)
  • Use if-else logic in Arduino programming

⚙️ Hardware Requirements

  • Arduino UNO
  • Push Button
  • LED
  • 220Ω resistor (for LED)
  • 10kΩ pull-down resistor (for button)
  • Breadboard and jumper wires

🔌 Circuit Connections

Component Arduino Pin Description
Button D8 Input pin to detect press
LED D7 Output pin to control LED
Button GND GND Common ground
LED GND GND (via 220Ω resistor) Current limiting resistor for LED

🧩 Logic:

  • When the button is pressed → Pin 8 reads HIGH → LED ON
  • When the button is released → Pin 8 reads LOW → LED OFF

💻 Arduino Code

const int button = 8;
const int led = 7;

unsigned char button_state;

void setup()
{
  pinMode(button, INPUT);
  pinMode(led, OUTPUT);
}

void loop()
{
  button_state = digitalRead(button);

  if(button_state == HIGH)
  {
    digitalWrite(led, HIGH);
  }
  else
  {
    digitalWrite(led, LOW);
  }
}

🚀 How It Works The push button sends a digital HIGH signal to pin 8 when pressed.

The Arduino reads this signal using digitalRead().

Based on the input, the LED is turned ON or OFF using digitalWrite().

🧰 Software Tools Arduino IDE (v2.0 or later)

Arduino UNO Board Drivers

📸 Output Behavior Button State LED State Pressed (HIGH) ON Released (LOW) OFF

About

A simple digital input-output project where an LED is controlled by a push button. When the button is pressed, the LED turns **ON**; when released, it turns **OFF** — the perfect beginner exercise to understand digital logic and I/O pins on Arduino.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages