ARDUINO LED CHASER (10+ PATTERNS)

The Arduino is a great platform for playing with electronics. It’s open source hardware and it has a great community behind it. Most of us tried Blinking LED using Arduino as a Beginner. Let’s do something cool using LED’s with Arduino. In this project, we will make LED’s blink in different patterns. The program has totally 11 different patterns. You can include more patterns if you like. 

Components :

  • 1 X Breadborad
  • 9 X LED
  • 9 X 220 ohm Resistors
  • Arduino Uno
  • Jumper Cables

Schematics :

Source Code :

Note :

  • Remove Tx / Rx Pins of Arduino while Uploading the Code.
  • Install the Required Library.
/*
      © Techtronic Harsh

    Youtube : http://bit.ly/33kxOOQ
    Instructables : https://www.instructables.com/member/...
    Instagram : https://instagram.com/techtronicharsh
    Website : http://techtronicharsh.com
    Telegram : https://t.me/techtronicharsh

*/
 void setup()   
 {  
  for (int i = 5; i <= 13; i++) // Set Pins 5 to 13 as Output  
  {  
   pinMode(i, OUTPUT);  
  }  
 }  
   
 void loop()  
 {  
  for(int i=0;i<5;i++)  { pattern1(); }     //pattern 1  
  for(int i=0;i<5;i++)  { pattern2(); }     //pattern 2  
  for(int i=0;i<5;i++)  { pattern3(); }     //pattern 3  
  for(int i=0;i<5;i++)  { pattern4(); }     //pattern 4  
  for(int i=0;i<5;i++)  { pattern5(); }     //pattern 5  
  for(int i=0;i<5;i++)  { pattern6(); }     //pattern 6  
  for(int i=0;i<5;i++)  { pattern7(); }     //pattern 7  
  for(int i=0;i<5;i++)  { pattern8(); }     //pattern 8  
  for(int i=0;i<5;i++)  { pattern9(); }     //pattern 9  
  for(int i=0;i<5;i++)  { pattern10(); }    //pattern 10  
  for(int i=0;i<25;i++) { pattern11(); }    //pattern 11  
  clear();  
  delay(5000);   
 }  
   
 void pattern1()  
 {  
  for(int i=5;i<14;i++)  
  {  
   digitalWrite(i,HIGH);  
   delay(100);  
   digitalWrite(i,LOW);  
  }  
 }  
   
 void pattern2()  
 {  
  for(int j=5; j<14; j++)  
  {  
   digitalWrite(j, HIGH);  
   delay(30);  
   digitalWrite(j, LOW);  
   delay(30);  
  }  
  for(int k = 15; k>5; k--)  
  {  
   digitalWrite(k, HIGH);  
   delay(30);  
   digitalWrite(k, LOW);  
   delay(30);  
  }  
 }  
   
 void pattern3()  
 {  
  for(int i=5;i<14;i++)  
  {  
   digitalWrite(i,HIGH);  
   delay(100);  
  }  
  for(int i=5;i<14;i++)  
  {  
   digitalWrite(i,LOW);  
   delay(100);  
  }   
 }  
   
 void pattern4()  
 {  
  for(int i = 15; i >= 5; i--)  
  {  
   digitalWrite(i, HIGH);  
   delay(20);  
   digitalWrite(i+1, LOW);  
   delay(20);  
  }  
  for(int i = 15; i >= 5; i--)  
  {  
   digitalWrite(i+1, HIGH);  
   delay(20);  
   digitalWrite(i+2, LOW);  
   delay(20);  
  }  
  for(int i = 15; i >= 5; i--)  
  {  
   digitalWrite(i+2, HIGH);  
   delay(20);  
   digitalWrite(i+3, LOW);  
   delay(20);  
  }  
  for(int i = 15; i >= 5; i--)  
  {  
   digitalWrite(i+3, HIGH);  
   delay(20);  
   digitalWrite(i+4, LOW);  
   delay(20);  
  }  
  for(int i = 15; i >= 5; i--)  
  {  
   digitalWrite(i+4, HIGH);  
   delay(20);  
   digitalWrite(i+5, LOW);  
   delay(20);  
  }  
  for(int i = 15; i >= 5; i--)  
  {  
   digitalWrite(i+5, HIGH);  
   delay(20);  
   digitalWrite(i+6, LOW);  
   delay(20);  
  }  
  for(int i = 15; i >= 5; i--)  
  {  
   digitalWrite(i+6, HIGH);  
   delay(20);  
   digitalWrite(i+7, LOW);  
   delay(20);  
  }  
  for(int i = 15; i >= 5; i--)  
  {  
   digitalWrite(i+7, HIGH);  
   delay(20);  
   digitalWrite(i+8, LOW);  
   delay(20);  
  }  
  for(int i = 15; i >= 5; i--)  
  {  
   digitalWrite(i+8, HIGH);  
   delay(20);  
   digitalWrite(i+9, LOW);  
   delay(20);  
  }  
  for(int i = 15; i >= 5; i--)  
  {  
   digitalWrite(i+9, HIGH);  
   delay(20);  
   digitalWrite(i+10, LOW);  
   delay(20);  
  }  
  for(int i = 15; i >= 5; i--)  
  {  
   digitalWrite(i+10, HIGH);  
   delay(20);  
   digitalWrite(i+11, LOW);  
   delay(20);  
  }  
  for(int i = 15; i >= 5; i--)  
  {  
   digitalWrite(i+13, HIGH);  
   delay(20);  
   digitalWrite(i, LOW);  
  }  
 }  
   
 void pattern5()  
 {  
  for(int j=5; j<14; j++)  
  {  
   digitalWrite(j, LOW);  
   delay(30);  
   digitalWrite(j, HIGH);  
   delay(30);  
   digitalWrite(j-2, LOW);  
   delay(30);  
   digitalWrite(j, HIGH);  
  }  
  for(int k = 15; k>5; k--)  
  {  
   digitalWrite(k, LOW);  
   delay(30);  
   digitalWrite(k, HIGH);  
   delay(30);  
   digitalWrite(k+2, LOW);  
   delay(30);  
   digitalWrite(k, HIGH);  
  }  
 }  
   
  void clear()  
  {  
   for(int i=5;i<14;i++)  
   {  
    digitalWrite(i,LOW);   
   }  
  }  
   
  void pattern6()  
  {  
   int count = 13;   
   
   for (int i = 5; i < 13; i++)   
   {  
    clear();  
    digitalWrite(i, HIGH);     
    digitalWrite(count, HIGH);   
    count--;  
    if (count != 9)   
    {  
     delay(100);  
    }  
   }  
   
   for (int i = 13; i > 5; i--)   
   {   
    clear();  
    digitalWrite(i, HIGH);   // chaser 1  
    digitalWrite(count, HIGH); // chaser 2  
    count++;  
    if (count != 10)   
    {  
     delay(100);  
    }    
   }   
  }  
   
 void pattern7()  
 {  
  for(int i=5; i<14; i++)  
   {  
    digitalWrite(i, HIGH);  
    delay(50);  
   }  
  for(int i=5; i<14; i++)  
   {  
   digitalWrite(i, LOW);  
   delay(50);  
   }  
    
    
  for(int i = 14; i>=5; i--)  
  {  
   digitalWrite(i, HIGH);  
   delay(50);  
  }  
  for(int i = 14; i>=5; i--)  
  {  
   digitalWrite(i, LOW);  
   delay(50);  
  }  
 }  
   
 void pattern8()  
 {  
  for(int j = 5; j <= 13; j++)  
  {  
   digitalWrite(j, HIGH);  
   delay(100);  
   j=j+1;  
  }  
     
  for(int j = 5; j <= 13; j++)  
  {  
   digitalWrite(j, LOW);  
   delay(100);  
  }  
    
  for(int k = 14; k > 5; k--)  
  {  
   digitalWrite(k, HIGH);  
   delay(100);  
   k=k-1;  
  }  
  for(int k = 14; k > 5; k--)  
  {  
   digitalWrite(k, LOW);  
   delay(100);  
  }  
 }  
   
 void pattern9()  
 {  
  {  
  digitalWrite(5,HIGH);  
  digitalWrite(7,HIGH);  
  digitalWrite(9,HIGH);  
  digitalWrite(11,HIGH);  
  digitalWrite(13,HIGH);  
  digitalWrite(6,LOW);  
  digitalWrite(8,LOW);  
  digitalWrite(10,LOW);  
  digitalWrite(12,LOW);   
  }  
  delay(150);  
  {  
  digitalWrite(5,LOW);  
  digitalWrite(7,LOW);  
  digitalWrite(9,LOW);  
  digitalWrite(11,LOW);  
  digitalWrite(13,LOW);  
  digitalWrite(6,HIGH);  
  digitalWrite(8,HIGH);  
  digitalWrite(10,HIGH);  
  digitalWrite(12,HIGH);  
  }  
  delay(150);  
 }  
   
 void pattern10()  
 {  
   {  
  digitalWrite(5,HIGH);  
  digitalWrite(6,HIGH);  
  digitalWrite(7,HIGH);  
  digitalWrite(8,HIGH);  
  digitalWrite(9,HIGH);  
  digitalWrite(10,LOW);  
  digitalWrite(11,LOW);  
  digitalWrite(12,LOW);  
  digitalWrite(13,LOW);   
  }  
  delay(150);  
  {  
  digitalWrite(9,HIGH);  
  digitalWrite(10,HIGH);  
  digitalWrite(11,HIGH);  
  digitalWrite(12,HIGH);  
  digitalWrite(13,HIGH);  
  digitalWrite(5,LOW);  
  digitalWrite(6,LOW);  
  digitalWrite(7,LOW);  
  digitalWrite(8,LOW);  
  }  
  delay(150);   
 }  
   
 void pattern11()   
 {  
  int randomled = random(5, 14);  
  digitalWrite(randomled, HIGH);  
  delay(50);  
  digitalWrite(randomled, LOW);  
  delay(50);  
 }  
   
/*
      © Techtronic Harsh

    Youtube : http://bit.ly/33kxOOQ
    Instructables : https://www.instructables.com/member/...
    Instagram : https://instagram.com/techtronicharsh
    Website : http://techtronicharsh.com
    Telegram : https://t.me/techtronicharsh

*/
Close Bitnami banner
Bitnami