In this tutorial, we'll go through the process of blinking multiple LEDs using the Arduino uno R4 WIFI (steps same for most Arduino boards) and a breadboard.
Before we get started check previous article on
how to blink a single LED 👉🏾 here
Materials Needed:
- Arduino Board (Ex: uno)
- Breadboard and jumper wires(x6)
- LEDs (x5)
- Resistor (270Ω) (x5)
- USB cable for Arduino
- Arduino IDE installed on your computer
Step 1: Set Up the Hardware:
Connect the short leg (cathode) of the LED to GND on the Arduino.
Connect the long leg (anode) of the LED to resistor ( 270Ω) and to pin 13 on the Arduino. (Use a jumper wire for it to reach to Arduino pin)
repeat the same for other Arduino digital pins as well 12, 11, 10, 9
You can connect the components differently on breadboard as long as you follow the same circuit its fine.
Step 2: Connect your Arduino board to your computer
Cables can be different depending on Arduino board. Some can use USB and others Type-C cables. Can connect depending on your board.
Step 3: Writing the codes
In your Arduino IDE add those codes.
// Blinking multiple LEDs
int ledPin1 = 13; // Pin number for the LED1
int ledPin2 = 12; // Pin number for the LED2
int ledPin3 = 11; // Pin number for the LED3
int ledPin4 = 10; // Pin number for the LED4
int ledPin5 = 9; // Pin number for the LED5
void setup() {
pinMode(ledPin1, OUTPUT); // Set the LED1 pin as an output
pinMode(ledPin2, OUTPUT); // Set the LED2 pin as an output
pinMode(ledPin3, OUTPUT); // Set the LED3 pin as an output
pinMode(ledPin4, OUTPUT); // Set the LED4 pin as an output
pinMode(ledPin5, OUTPUT); // Set the LED5 pin as an output
}
void loop() {
digitalWrite(ledPin1, HIGH); // Turn the LED1 on
delay(50); // Wait for 50 milliseconds
digitalWrite(ledPin1, LOW); // Turn the LED1 off
delay(50); // Wait for 50 milliseconds
digitalWrite(ledPin2, HIGH); // Turn the LED2 on
delay(50); // Wait for 50 milliseconds
digitalWrite(ledPin2, LOW); // Turn the LED2 off
delay(50); // Wait for 50 milliseconds
digitalWrite(ledPin3, HIGH); // Turn the LED3 on
delay(50); // Wait for 50 milliseconds
digitalWrite(ledPin3, LOW); // Turn the LED3 off
delay(50); // Wait for 50 milliseconds
digitalWrite(ledPin4, HIGH); // Turn the LED4 on
delay(50); // Wait for 50 milliseconds
digitalWrite(ledPin4, LOW); // Turn the LED4 off
delay(50); // Wait for 50 milliseconds
digitalWrite(ledPin5, HIGH); // Turn the LED5 on
delay(50); // Wait for 50 milliseconds
digitalWrite(ledPin5, LOW); // Turn the LED5 off
delay(50); // Wait for 50 milliseconds
}
Step 4: Uploading the codes
Now, make sure that in your Arduino IDE the correct board is selected and click on the upload button.
Your codes should be uploaded successfully.
If the steps above were followed, the led will be blinking every one second 🎉
You can read more on the article and check demo 👉🏾here
Top comments (2)
Thanks for the tutorial! Blinking multiple LEDs with Arduino is a great project for beginners to learn about programming Smd screens and circuit connections. Looking forward to trying it out.
Discover Outstanding SMD Screens in Pakistan – Reliable, Affordable, and High-Quality Display Solutions for All Your Needs. Shop Now for the Best Deals!