5 Kilo-watt Led Chaser

Source Code of Led Chaser :-

 
#define t   30
#define t1  20
#define t2  100
#define t3  50

void setup() {
  
  for (int i = 1; i <= 3; i++) {
    pinMode(i, OUTPUT);
  }
}

void loop(){

effect_1();
effect_1();

 effect_2();
 effect_2();

 effect_3();
 effect_3();

 effect_4();
 effect_4();
  }

void effect_1()
{
for(int i=1; i<3; i++){
digitalWrite(i, HIGH);
delay(t1);
digitalWrite(i+1, HIGH);
delay(t1);
digitalWrite(i+2, HIGH);
delay(t1);
digitalWrite(i, LOW);
delay(t1);
digitalWrite(i+1, LOW);
delay(t1);
}
for(int i=3; i>1; i--){
digitalWrite(i, HIGH);
delay(t1);
digitalWrite(i-1, HIGH);
delay(t1);
digitalWrite(i-2, HIGH);
delay(t1);
digitalWrite(i, LOW);
delay(t1);
digitalWrite(i-1, LOW);
delay(t1);
}
}


void effect_2()
{
for(int i=1; i<3; i++){
  digitalWrite(i, HIGH);
  delay(t3);
}
for(int i=1; i<3; i++){
  digitalWrite(i, LOW);
  delay(t3);
}


for(int i = 3; i>=1; i--){
  digitalWrite(i, HIGH);
  delay(t3);
}
for(int i = 3; i>=1; i--){
  digitalWrite(i, LOW);
  delay(t3);
}
}
  


void effect_3()
{
for(int j=1; j<3; j++){
  digitalWrite(j, LOW);
  delay(t);
  digitalWrite(j, HIGH);
  delay(t);
  digitalWrite(j-2, LOW);
  delay(t);
  digitalWrite(j, HIGH);
}
for(int k = 3; k>1; k--){
  digitalWrite(k, LOW);
  delay(t);
  digitalWrite(k, HIGH);
  delay(t);
  digitalWrite(k+2, LOW);
  delay(t);
  digitalWrite(k, HIGH);
}
for(int k = 1; k<3; k++){
  digitalWrite(k, LOW);
  delay(t);
  digitalWrite(k, HIGH);
  delay(t);
  digitalWrite(k-2, LOW);
  delay(t);
  digitalWrite(k, HIGH);
}
for(int k = 3; k>1; k--){
  digitalWrite(k, LOW);
  delay(t);
  digitalWrite(k, HIGH);
  delay(t);
  digitalWrite(k+4, LOW);
  delay(t);
  digitalWrite(k, HIGH);
}
for(int k = 1; k<3; k++){
  digitalWrite(k, LOW);
  delay(t);
  digitalWrite(k, HIGH);
  delay(t);
  digitalWrite(k-4, LOW);
  delay(t);
  digitalWrite(k, HIGH);
} 
}

void effect_4()
{
for(int j=1; j<3; j++){
  digitalWrite(j, HIGH);
  delay(t);
  digitalWrite(j+2, LOW);
  delay(t);
}
for(int k = 3; k>1; k--){
  digitalWrite(k, HIGH);
  delay(t);
  digitalWrite(k+2, LOW);
  delay(t);
}
}


void clear(void)
{
  for (int i = 1; i <= 3; i++) {
    digitalWrite(i, LOW);
  }
}

Leave a Comment