🔰 Project: Multiple Button LED Control using Arduino Nano

🔰 Project: Multiple Button LED Control using Arduino Nano

💡 Project Overview

In this project, you’ll use three push buttons to independently control three LEDs connected to your Arduino Nano.
Each button controls one LED — for example:

  • Button 1 turns ON/OFF the Red LED
  • Button 2 turns ON/OFF the Yellow LED
  • Button 3 turns ON/OFF the Green LED

This is a perfect beginner project to learn digital input–output control and button debouncing in Arduino.


⚙️ Components Required

ComponentQuantityDescription
Arduino Nano1Main microcontroller
LEDs (Red, Yellow, Green)3Output indicators
Push Buttons3Input switches for controlling LEDs
220Ω Resistors3For LEDs
10kΩ Resistors3Pull-down resistors (if not using INPUT_PULLUP)
Breadboard1For connections
Jumper WiresSeveralFor wiring

🧩 Circuit Connection (Text Description)

You can reuse the same LED wiring:

LED ColorArduino Nano PinConnection Details
LED 1 (Red)A3Anode (+) → A3 via 220Ω resistor, Cathode (–) → GND
LED 2 (Yellow)A4Anode (+) → A4 via 220Ω resistor, Cathode (–) → GND
LED 3 (Green)A5Anode (+) → A5 via 220Ω resistor, Cathode (–) → GND

🖲️ Button Connections

We’ll use digital pins D2, D3, and D4 for the three buttons.

ButtonArduino PinConnection Details
Button 1D2One leg → D2, other leg → GND
Button 2D3One leg → D3, other leg → GND
Button 3D4One leg → D4, other leg → GND

Each button pin uses Arduino’s internal pull-up resistor, so no external 10kΩ resistor is needed.

🪛 Wiring Summary

A3 → 220Ω → LED1 → GND
A4 → 220Ω → LED2 → GND
A5 → 220Ω → LED3 → GND

D2 → Button 1 → GND
D3 → Button 2 → GND
D4 → Button 3 → GND

✅ LEDs: OUTPUT
✅ Buttons: INPUT_PULLUP


💻 Arduino Code – Multiple Button LED Control

// Multiple Button LED Control using Arduino Nano
// LEDs on A3, A4, A5; Buttons on D2, D3, D4

#define LED1 A3
#define LED2 A4
#define LED3 A5

#define BTN1 2
#define BTN2 3
#define BTN3 4

void setup() {
  pinMode(LED1, OUTPUT);
  pinMode(LED2, OUTPUT);
  pinMode(LED3, OUTPUT);

  pinMode(BTN1, INPUT_PULLUP);
  pinMode(BTN2, INPUT_PULLUP);
  pinMode(BTN3, INPUT_PULLUP);
}

void loop() {
  // Buttons are active LOW (pressed = LOW)
  if (digitalRead(BTN1) == LOW) {
    digitalWrite(LED1, HIGH);
  } else {
    digitalWrite(LED1, LOW);
  }

  if (digitalRead(BTN2) == LOW) {
    digitalWrite(LED2, HIGH);
  } else {
    digitalWrite(LED2, LOW);
  }

  if (digitalRead(BTN3) == LOW) {
    digitalWrite(LED3, HIGH);
  } else {
    digitalWrite(LED3, LOW);
  }
}

🧠 Code Explanation

  1. Pin Setup:
    • LEDs are connected to A3, A4, A5 (outputs).
    • Buttons are connected to D2, D3, D4 (inputs with internal pull-up).
  2. INPUT_PULLUP Logic:
    • Each button reads HIGH when not pressed.
    • When pressed, it connects to GND → reads LOW.
  3. Loop Section:
    • Each LED turns ON when its button is pressed.
    • When the button is released, the LED turns OFF.
  4. No delay() Used:
    • The program continuously checks all button states, so it’s very responsive.

🔄 Output Behavior

  • Press Button 1 → LED1 (A3) turns ON
  • Press Button 2 → LED2 (A4) turns ON
  • Press Button 3 → LED3 (A5) turns ON
  • Releasing any button turns OFF its LED

💬 Project Summary

This project demonstrates:

  • Multiple input handling
  • Independent LED control
  • Use of internal pull-up resistors

This Post Has One Comment

Leave a Reply