LED- Chaser Festival Light With Arduino
To make this project you all need some simple components.
Component-
- Arduino UNO
- 220-ohm resistor
- LED x8
- Jumper wires
- Breadboard
1st, put all LEDs on the breadboard and set the (-) terminal common. then connect every led with pin 2 to pin 9 of the Arduino board using jumper wires.
After complete all setup lets connect the ground wire via a 220ohm resistor. according to this diagram.
Now connect your arduino board with your computer or mobile via USB cable, and upload the following code.
--------------------------------------------------------------------------------------------------------
Here Is the Code -
int ledPins[] = {2, 3, 4, 5, 6, 7, 8, 9}; // Pins for the LEDs
int numbers = 8;
void setup() {
// Initialize each LED pin as output
for (int i = 0; i < numLeds; i++) {
pinMode(ledPins[i], OUTPUT);
}
}
void loop() {
// Forward sequence (left to right)
for (int i = 0; i < numLeds; i++) {
digitalWrite(ledPins[i], HIGH); // Turn on the current LED
delay(100); // Delay to create the running effect
digitalWrite(ledPins[i], LOW); // Turn off the current LED
}
// Backward sequence (right to left)
for (int i = numLeds - 1; i >= 0; i--) {
digitalWrite(ledPins[i], HIGH); // Turn on the current LED
delay(100); // Delay to create the running effect
digitalWrite(ledPins[i], LOW); // Turn off the current LED
}
}
----------------------------------------------------------
After uploading this code your project will start working.
If there is any conclusion or question please make sure to leave a comment.
0 Comments