💡 2. Project Title: Turn LED ON using Push Button (Arduino)
🧠 Project Description
This simple project demonstrates how to use a push button to control an LED.
When you press the button, the LED connected to pin 8 will turn ON; when you release it, the LED will turn OFF.
This teaches you the concept of digital input (button) and digital output (LED) — the base of all Arduino-controlled devices.
⚙️ Components Required
| Component | Quantity | Description |
|---|---|---|
| Arduino UNO / Nano | 1 | Main microcontroller board |
| LED | 1 | Output device |
| 220Ω Resistor | 1 | Protects the LED from high current |
| Push Button | 1 | Used as input switch |
| Breadboard | 1 | For circuit setup |
| Jumper Wires | Few | For connections |
🔌 Circuit Connections (Based on Your Wiring)
| Component | Arduino Pin | Other Connection |
|---|---|---|
| LED (Anode +) | D8 | Through 220Ω resistor |
| LED (Cathode −) | GND | — |
| Push Button | D7 | One end connected to D7 |
| Push Button | 5V | Other end connected to +5V |
| Internal Pull-Down | GND | Managed via software logic |
⚙️ Circuit Explanation
- When the push button is not pressed, the input pin (D7) reads LOW (0).
- When you press the button, it connects 5V to pin D7, making it HIGH (1).
- The Arduino detects this HIGH signal and turns the LED ON by sending a HIGH output to pin D8.
- Once released, the pin returns LOW, and the LED turns OFF.
🧩 You are using the Arduino’s INPUT_PULLDOWN logic manually (since the button connects to 5V).
If your board doesn’t have a physical pulldown resistor, you can use software logic or wire one (optional).
💻 Arduino Code
// Turn LED ON using Push Button
int ledPin = 8; // LED connected to pin 8
int buttonPin = 7; // Push button connected to pin 7
int buttonState = 0; // Variable to store button state
void setup() {
pinMode(ledPin, OUTPUT); // LED as output
pinMode(buttonPin, INPUT); // Button as input
}
void loop() {
buttonState = digitalRead(buttonPin); // Read button input
if (buttonState == HIGH) {
digitalWrite(ledPin, HIGH); // Turn LED ON
} else {
digitalWrite(ledPin, LOW); // Turn LED OFF
}
}
🧠 Code Explanation
| Line | Description |
|---|---|
int ledPin = 8; | LED connected to digital pin 8 |
int buttonPin = 7; | Push button connected to pin 7 |
pinMode(buttonPin, INPUT); | Reads signal from the button |
digitalRead(buttonPin); | Checks if the button is pressed (HIGH) or not (LOW) |
digitalWrite(ledPin, HIGH); | Turns LED ON when button is pressed |
digitalWrite(ledPin, LOW); | Turns LED OFF when button is released |
⚡ Working Principle
- The push button acts as a switch.
- When pressed, current flows from 5V → button → pin 7, signaling Arduino to light up the LED.
- When released, pin 7 goes LOW, and the LED turns OFF.
🧪 Experiment Ideas
- Modify the code so the LED stays ON even after releasing the button (toggle effect).
- Use two buttons — one for turning ON, another for turning OFF.
- Add a buzzer along with LED for feedback.
✅ Learning Outcome
After completing this project, you’ll understand:
- How to read digital inputs from a button.
- How to control outputs based on input signals.
- The concept of HIGH and LOW logic in Arduino.
Would you like me to make a circuit diagram (with Arduino, button, LED, and resistor) for your exact pin setup (LED on D8, button on D7 → 5V)?
Pingback: Arduino Demo Kit Projects - Motion Demo Kit (With Arduino) - Project List - EDGENext Learning