Objective:
The goal of this project is to blink Multiple LEDs connected to the Arduino board, with each LED turning on for 1 second, followed by a 1-second off period, before moving on to the next LED. This sequential blinking is commonly used in various applications such as visual indicators or patterns in more complex projects.
Components Required:
- Arduino board (e.g., Uno, Nano)
- 3 LEDs
- 3 resistors (220Ω – 330Ω)
- Jumper wires
- Breadboard (optional)
This project is ideal for beginners to understand how to control multiple outputs and create basic timing-based behavior in an embedded system
Wiring:
- Connect the long leg (anode) of each LED to the respective Arduino pins (2, 3, 4).
- Connect the short leg (cathode) of each LED to ground (GND) through a current-limiting resistor (typically 220Ω to 330Ω for each LED).
How it Works:
- Pin Assignments: The LEDs are connected to digital pins 2, 3, and 4. You can adjust these pins based on your actual setup.
- Setup: In the
setup()
function, the LED pins are configured as output. - Loop: In the
loop()
, each LED is turned on, then turned off with a 1-second delay between each action. After LED 1 blinks, the code moves on to LED 2, and then to LED 3.
const int led1 = 2; // Pin for LED 1
const int led2 = 3; // Pin for LED 2
const int led3 = 4;
void setup() {
// Set LED pins as OUTPUT
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
}
void loop() {
// Blink LED 1
digitalWrite(led1, HIGH);
delay(1000);
digitalWrite(led1, LOW);
delay(1000);
// Blink LED 2
digitalWrite(led2, HIGH);
delay(1000);
digitalWrite(led2, LOW);
delay(1000);
// Blink LED 3
digitalWrite(led3, HIGH);
delay(1000);
digitalWrite(led3, LOW);
delay(1000);
}
Result:
- The LEDs will blink one by one, with each LED staying on for 1 second, then turning off for 1 second before moving on to the next LED.