Anjali Shaw
Published © GPL3+

Chasing Light Effect

Have u wondered how diwali led's lit up in any particular way. Haven't let's see here

BeginnerFull instructions provided30 minutes880
Chasing Light Effect

Things used in this project

Hardware components

LED (generic)
LED (generic)
any combination of colors you can take
×10
Jumper wires (generic)
Jumper wires (generic)
×1
Arduino UNO
Arduino UNO
you need only arduino uno board
×1
Breadboard (generic)
Breadboard (generic)
×1
Resistor 330 ohm
Resistor 330 ohm
×10

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

circuit connection

connect the leds sequentially from 4 to 13

Code

code of the project

Arduino
you can write the code or paste it
i will personally recommend you to write it
byte ledPin[]={4,5,6,7,8,9,10,11,12,13};//to define the led's pin
int ledDelay(65);
int direction =1;
int currentLed;
unsigned long changeTime;//this is taken as unsigned because of the function in which it will be used in future
void setup() {
 for (int x=0;x<10;x++)
 {
   pinMode(ledPin[x],OUTPUT);
 }
 changeTime=millis();
}
void changeLed()
{
 for( int x=0;x<10;x++)
 {
   digitalWrite(ledPin[x],LOW);
 }
 digitalWrite(ledPin[currentLed],HIGH);
 currentLed+=direction;
 if (currentLed==9)
 {
   direction=-1;
 }
 if (currentLed==0)
 {
   direction =1;
 }
}
void loop() {
 // put your main code here, to run repeatedly:
if ((millis()-changeTime)>ledDelay)
{
 changeLed();
 changeTime=millis();
}
}

Credits

Anjali Shaw

Anjali Shaw

10 projects • 7 followers

Comments