Beautiful decorative effects of LEDs using Arduino

This is a very interesting project, which you will love to construct using 8 LEDs and Arduino UNO development board. Burn the following code into your Arduino UNO development board and construct the circuit on breadboard as show in following FritzingFritzing Fritzing is an electronics design and prototyping platform for makers, hobbyists, and educators. Easily create and document your electronic projects and use them for presentation in the form of slideshow or anything else. drawing. Then connect power to the circuit to see beautiful decorative effects of LEDs.

Its a great interesting project for Arduino Lovers…!

Connection Diagram

Beautiful decorative effects of LEDs using Arduino
Beautiful decorative effects of LEDs using Arduino

The Code

/*
 * Multi LEDs Decorative Effects
 * Vidyasagar Academy, www.vsa.edu.in
 * Date: 02.09.2022
 */

 int LED1=0;
 int LED2=1;
 int LED3=2;
 int LED4=3;
 int LED5=4;
 int LED6=5;
 int LED7=6;
 int LED8=7;
 int i;

 /* user defined functions for each LED seperately */
 void on1()
 {
  digitalWrite(LED1,HIGH);
 }
 void off1()
 {
  digitalWrite(LED1,LOW);
 }

 void on2()
 {
  digitalWrite(LED2,HIGH);
 }
 void off2()
 {
  digitalWrite(LED2,LOW);
 }

 void on3()
 {
  digitalWrite(LED3,HIGH);
 }
 void off3()
 {
  digitalWrite(LED3,LOW);
 }

 void on4()
 {
  digitalWrite(LED4,HIGH);
 }
 void off4()
 {
  digitalWrite(LED4,LOW);
 }

 void on5()
 {
  digitalWrite(LED5,HIGH);
 }
 void off5()
 {
  digitalWrite(LED5,LOW);
 }

 void on6()
 {
  digitalWrite(LED6,HIGH);
 }
 void off6()
 {
  digitalWrite(LED6,LOW);
 }

 void on7()
 {
  digitalWrite(LED7,HIGH);
 }
 void off7()
 {
  digitalWrite(LED7,LOW);
 }

 void on8()
 {
  digitalWrite(LED8,HIGH);
 }
 void off8()
 {
  digitalWrite(LED8,LOW);
 }

 void all_off() // all LEDs off
 {
  digitalWrite(LED1,LOW);
  digitalWrite(LED2,LOW);
  digitalWrite(LED3,LOW);
  digitalWrite(LED4,LOW);
  digitalWrite(LED5,LOW);
  digitalWrite(LED6,LOW);
  digitalWrite(LED7,LOW);
  digitalWrite(LED8,LOW);
 }
 
 void setup()
 {
  pinMode(LED1,OUTPUT);
  pinMode(LED2,OUTPUT);
  pinMode(LED3,OUTPUT);
  pinMode(LED4,OUTPUT);
  pinMode(LED5,OUTPUT);
  pinMode(LED6,OUTPUT);
  pinMode(LED7,OUTPUT);
  pinMode(LED8,OUTPUT);
 }

 void loop()
 {
  // all LEDs blink on/off 6 times
  for(i=1;i<6;i++)
  {
    on1();
    on2();
    on3();
    on4();
    on5();
    on6();
    on7();
    on8();
    delay(1000);
    off1();
    off2();
    off3();
    off4();
    off5();
    off6();
    off7();
    off8();
    delay(1000);
  }

 all_off();
 delay(300);

   // 4 LEDs blink alternately 6 times
  for(i=1;i<6;i++)
  {
    on1();
    on2();
    on3();
    on4();
    off5();
    off6();
    off7();
    off8();
    delay(100);
    off1();
    off2();
    off3();
    off4();    
    on4();
    on5();
    on6();
    on7();
    delay(100);
  }

 all_off();
 delay(300);

   // 2 LEDs blink (ascending) one-by-one in row 6 times
  for(i=1;i<6;i++)
  {
    on1();
    on2();
    off3();
    off4();
    off5();
    off6();
    off7();
    off8();
    delay(100);
    on3();
    on4();
    off1();
    off2();
    off5();
    off6();
    off7();
    off8();
    delay(100);
    on5();
    on6();
    off1();
    off2();
    off3();
    off4();
    off7();
    off8();
    delay(100);
    on7();
    on8();
    off1();
    off2();
    off3();
    off4();
    off5();
    off6();
    delay(100);
  }

 all_off();
 delay(300);

   // 2 LEDs blink (descending) one-by-one in row 6 times
  for(i=1;i<6;i++)
  {
    on7();
    on8();
    off1();
    off2();
    off3();
    off4();
    off5();
    off6();
    delay(100);
    on5();
    on6();
    off1();
    off2();
    off3();
    off4();
    off7();
    off8();
    delay(100);
    on3();
    on4();
    off1();
    off2();
    off5();
    off6();
    off7();
    off8();
    delay(100);
    on1();
    on2();
    off3();
    off4();
    off5();
    off6();
    off7();
    off8();
    delay(100);
  }

 all_off();
 delay(300);

   // Chasing effect ascending/descending 6 times
  for(i=1;i<6;i++)
  {
    on1();
    delay(100);
    on2();
    delay(100);
    on3();
    delay(100);
    on4();
    delay(100);
    on5();
    delay(100);
    on6();
    delay(100);
    on7();
    delay(100);
    on8();
    delay(1000);
    off8();
    delay(100); // here delay is 1 sec 
    off8();
    delay(100);
    off7();
    delay(100);
    off6();
    delay(100);
    off5();
    delay(100);
    off4();
    delay(100);
    off3();
    delay(100);
    off2();
    delay(100);
    off1();
    delay(100);
  }

 all_off();
 delay(300);

   // Running effect ascending 6 times
  for(i=1;i<6;i++)
  {
    on1();
    off2();
    off3();
    off4();
    off5();
    off6();
    off7();
    off8();
    delay(100);
    on2();
    off1();
    off3();
    off4();
    off5();
    off6();
    off7();
    off8();
    delay(100);
    on3();
    off1();
    off2();
    off4();
    off5();
    off6();
    off7();
    off8();
    delay(100);
    on4();
    off1();
    off2();
    off3();
    off5();
    off6();
    off7();
    off8();
    delay(100);
    on5();
    off1();
    off2();
    off3();
    off4();
    off6();
    off7();
    off8();
    delay(100);
    on6();
    off1();
    off2();
    off3();
    off4();
    off5();
    off7();
    off8();
    delay(100);
    on7();
    off1();
    off2();
    off3();
    off4();
    off5();
    off6();
    off8();
    delay(100);
    on8();
    off1();
    off2();
    off3();
    off4();
    off5();
    off6();
    off7();
    delay(100);
  }

 all_off();
 delay(300);

   // Running effect desceding 6 times
  for(i=1;i<6;i++)
  {
    on8();
    off7();
    off6();
    off5();
    off4();
    off3();
    off2();
    off1();
    delay(100);
    on7();
    off8();
    off6();
    off5();
    off4();
    off3();
    off2();
    off1();
    delay(100);
    on6();
    off8();
    off7();
    off5();
    off4();
    off3();
    off2();
    off1();
    delay(100);
    on5();
    off7();
    off6();
    off8();
    off4();
    off3();
    off2();
    off1();
    delay(100);
    on4();
    off7();
    off6();
    off5();
    off8();
    off3();
    off2();
    off1();
    delay(100);
    on3();
    off7();
    off6();
    off5();
    off4();
    off8();
    off2();
    off1();
    delay(100);
    on2();
    off7();
    off6();
    off5();
    off4();
    off3();
    off8();
    off1();
    delay(100);
    on1();
    off7();
    off6();
    off5();
    off4();
    off3();
    off2();
    off8();
    delay(100);    
  }

 all_off();
 delay(300);
 }


Share on your network!
Dattaraj Vidyasagar
Dattaraj Vidyasagar

Author on this website. He is veteran of Core Electronics since last 36+ years. ATL Mentor of Change, Niti Ayog, Govt. of India, Google Certified Educator, International Robotics Trainer and author of 18 books on electronics, robotics, programming languages and web designing... ➤➤

Leave a Reply

Your email address will not be published. Required fields are marked *