Create Your LED Chaser Project Using Wokwi Arduino Simulator

  1. Open the wokwi Arduino simulation for a simple LED blink page here. Note that wokwi Arduino simulator even works on your mobile browser as well
  2. Once it is open, you can see two sections. To the left is the Editor window. Simulation windows is in the Right.
  3. diagram.json file is used to define the new elements and their connections respectively. Go ahead and have a look once. The ReadMe file is to share the information about the project and the source of the code etc.
  4. I have renamed the in the file from blink to LED chaser to make it more meaningful.

Please leave a comment if you have any questions. I will be glad to help you out

We will see the changes done in the INO file and JSON file

New Contents of the INO and Diagram.json File (you Can Copy and Paste It)

//initializing a variable for digital pin 2 to 13
int led1 = 2;
int led2 = 3;
int led3 = 4;
int led4 = 5;
int led5 = 6;
int led6 = 7;
int led7 = 8;
int led8 = 9;
int led9 = 10;
int led10 = 11;
int led11 = 12;

//Arduino 7 Effect code:-

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

void setup({
  // set up pins 2 to 13 as outputs
  for (int i = 2; i <= 13; i++) {
    pinMode(i, OUTPUT);
  }
}
/////////////////////////////////////////////////////////////////////////////////Effect 1
void loop(){

effect_1();
effect_1();

 effect_2();
 effect_2();

 effect_3();
 effect_3();

 effect_4();
 effect_4();

 effect_5();
 effect_5();

 effect_6();
 effect_6();

 effect_7();
 effect_7();
  }
//left to right and right to left
void effect_1()
{
for(int i=2; i<14; 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=13; 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);
}
}
/////////////////////////////////////////////////////////////////////////////////Effect 2
void effect_2()
{
int count = 13// keeps track of second LED movement

  // move first LED from left to right and second from right to left
  for (int i = 2; i < 13; i++) {
    clear();
    digitalWrite(i, HIGH);      // chaser 1
    digitalWrite(count, HIGH); // chaser 2
    count--;
    // stop LEDs from appearing to stand still in the middle
    if (count != 7) {
      delay(t2);
    }
  }

  // move first LED from right to left and second LED from left to right
  for (int i = 13; i > 2; i--) {
    clear();
    digitalWrite(i, HIGH);      // chaser 1
    digitalWrite(count, HIGH); // chaser 2
    count++;
    // stop LEDs from appearing to stand still in the middle
    if (count != 8) {
      delay(t2);
    }
  }
}

////////////////////////////////////////////////////////////////////////////////Effect 3

void effect_3()
{
for(int i=2; i<14; i++){
  digitalWrite(i, HIGH);
  delay(t3);
}
for(int i=2; i<14; i++){
  digitalWrite(i, LOW);
  delay(t3);
}

for(int i = 14; i>=2; i--){
  digitalWrite(i, HIGH);
  delay(t3);
}
for(int i = 14; i>=2; i--){
  digitalWrite(i, LOW);
  delay(t3);
}
}
  ///////////////////////////////////////////////////////////////////////////Effect 4
void effect_4()
{
for(int j = 2; j <= 13; j++){
  digitalWrite(j, HIGH);
  delay(t2);
  j=j+1;
  }
for(int j = 2; j <= 13; j++){
  digitalWrite(j, LOW);
  delay(t2);
  }

  for(int k = 15; k > 2; k--){
  digitalWrite(k, HIGH);
  delay(t2);
  k=k-1;
  }
for(int k = 15; k > 2; k--){
  digitalWrite(k, LOW);
  delay(t2);
  }
}
//////////////////////////////////////////////////////////////////////////////Effect 5
  void effect_5()
{
 for(int pin = 13; pin >= 2; pin--)
  {
  digitalWrite(pin, HIGH);
  delay(t1);
  digitalWrite(pin+1, LOW);
  delay(t1);
  }
  for(int pin = 13; pin >= 2; pin--)
  {
  digitalWrite(pin+1, HIGH);
  delay(t1);
  digitalWrite(pin+2, LOW);
  delay(t1);
  }
  for(int pin = 13; pin >= 2; pin--)
  {
  digitalWrite(pin+2, HIGH);
  delay(t1);
  digitalWrite(pin+3, LOW);
  delay(t1);
  }
  for(int pin = 13; pin >= 2; pin--)
  {
  digitalWrite(pin+3, HIGH);
  delay(t1);
  digitalWrite(pin+4, LOW);
  delay(t1);
  }
    for(int pin = 13; pin >= 2; pin--)
  {
  digitalWrite(pin+4, HIGH);
  delay(t1);
  digitalWrite(pin+5, LOW);
  delay(t1);
  }
  for(int pin = 13; pin >= 2; pin--)
  {
  digitalWrite(pin+5, HIGH);
  delay(t1);
  digitalWrite(pin+6, LOW);
  delay(t1);
  }
  for(int pin = 13; pin >= 2; pin--)
  {
  digitalWrite(pin+6, HIGH);
  delay(t1);
  digitalWrite(pin+7, LOW);
  delay(t1);
  }
   for(int pin = 13; pin >= 2; pin--)
  {
  digitalWrite(pin+7, HIGH);
  delay(t1);
  digitalWrite(pin+8, LOW);
  delay(t1);
  }
  for(int pin = 9; pin >= 2; pin--)
  {
  digitalWrite(pin+8, HIGH);
  delay(t1);
  digitalWrite(pin+9, LOW);
  delay(t1);
  }
    for(int pin = 9; pin >= 2; pin--)
  {
  digitalWrite(pin+9, HIGH);
  delay(t1);
  digitalWrite(pin+10, LOW);
  delay(t1);
  }
  for(int pin = 9; pin >= 2; pin--)
  {
  digitalWrite(pin+10, HIGH);
  delay(t1);
  digitalWrite(pin+11, LOW);
  delay(t1);
  }
  for(int pin = 14; pin >= 2; pin--)
  {
  digitalWrite(pin+11, HIGH);
  delay(t1);
  }
  for(int pin = 13; pin >= 2; pin--)
  {
    digitalWrite(pin, LOW);
  delay(t1);
    }
  }
  /////////////////////////////////////////////////////////////////////////////Effect 6
void effect_6()
{
for(int j=2; j<14; j++){
  digitalWrite(j, LOW);
  delay(t);
  digitalWrite(j, HIGH);
  delay(t);
  digitalWrite(j-2, LOW);
  delay(t);
  digitalWrite(j, HIGH);
}
for(int k = 15; k>2; k--){
  digitalWrite(k, LOW);
  delay(t);
  digitalWrite(k, HIGH);
  delay(t);
  digitalWrite(k+2, LOW);
  delay(t);
  digitalWrite(k, HIGH);
}
for(int k = 2; k<14; k++){
  digitalWrite(k, LOW);
  delay(t);
  digitalWrite(k, HIGH);
  delay(t);
  digitalWrite(k-2, LOW);
  delay(t);
  digitalWrite(k, HIGH);
}
for(int k = 15; k>2; k--){
  digitalWrite(k, LOW);
  delay(t);
  digitalWrite(k, HIGH);
  delay(t);
  digitalWrite(k+4, LOW);
  delay(t);
  digitalWrite(k, HIGH);
}
for(int k = 2; k<14; k++){
  digitalWrite(k, LOW);
  delay(t);
  digitalWrite(k, HIGH);
  delay(t);
  digitalWrite(k-4, LOW);
  delay(t);
  digitalWrite(k, HIGH);
} 
}
///////////////////////////////////////////////////////////////////////////////////Effect 7
void effect_7()
{
for(int j=2; j<14; j++){
  digitalWrite(j, HIGH);
  delay(t);
  digitalWrite(j+2, LOW);
  delay(t);
}
for(int k = 15; k>2; k--){
  digitalWrite(k, HIGH);
  delay(t);
  digitalWrite(k+2, LOW);
  delay(t);
}
}

// function to switch all LEDs off
void clear(void)
{
  for (int i = 2; i <= 13; i++) {
    digitalWrite(i, LOW);
  }
}

--

{
  "version": 1,
  "author": "Uri Shaked",
  "editor": "wokwi",
  "parts": [
    { "id": "uno", "type": "wokwi-arduino-uno", "top": 300, "left": 20 },
    { "id": "r13", "type": "wokwi-resistor", "top": 67, "left": 115, "rotate": 90, "attrs": {"value": "220"} },
    { "id": "r12", "type": "wokwi-resistor", "top": 67, "left": 135, "rotate": 90, "attrs": {"value": "220"} },
    { "id": "r11", "type": "wokwi-resistor", "top": 67, "left": 155, "rotate": 90, "attrs": {"value": "220"} },
    { "id": "r10", "type": "wokwi-resistor", "top": 67, "left": 175, "rotate": 90, "attrs": {"value": "220"} },
    { "id": "r9", "type": "wokwi-resistor", "top": 67, "left": 195, "rotate": 90, "attrs": {"value": "220"} },
    { "id": "r8", "type": "wokwi-resistor", "top": 67, "left": 215, "rotate": 90, "attrs": {"value": "220"} },
    { "id": "r7", "type": "wokwi-resistor", "top": 67, "left": 235, "rotate": 90, "attrs": {"value": "220"} },
    { "id": "r6", "type": "wokwi-resistor", "top": 67, "left": 255, "rotate": 90, "attrs": {"value": "220"} },
    { "id": "r5", "type": "wokwi-resistor", "top": 67, "left": 275, "rotate": 90, "attrs": {"value": "220"} },
    { "id": "r4", "type": "wokwi-resistor", "top": 67, "left": 295, "rotate": 90, "attrs": {"value": "220"} },
    { "id": "r3", "type": "wokwi-resistor", "top": 67, "left": 315, "rotate": 90, "attrs": {"value": "220"} },
    { "id": "r2", "type": "wokwi-resistor", "top": 67, "left": 335, "rotate": 90, "attrs": {"value": "220"} },

    { "id": "led13", "type": "wokwi-led", "left": 120, "top": -20, "attrs": { "color": "blue" }},
    { "id": "led12", "type": "wokwi-led", "left": 140, "top": -20, "attrs": { "color": "blue" }},
    { "id": "led11", "type": "wokwi-led", "left": 160, "top": -20, "attrs": { "color": "blue" }},
    { "id": "led10", "type": "wokwi-led", "left": 180, "top": -20, "attrs": { "color": "blue" }},
    { "id": "led9", "type": "wokwi-led", "left": 200, "top": -20, "attrs": { "color": "blue" }},
    { "id": "led8", "type": "wokwi-led", "left": 220, "top": -20, "attrs": { "color": "blue" }},
    { "id": "led7", "type": "wokwi-led", "left": 240, "top": -20, "attrs": { "color": "blue" }},    
    { "id": "led6", "type": "wokwi-led", "left": 260, "top": -20, "attrs": { "color": "blue" }},
    { "id": "led5", "type": "wokwi-led", "left": 280, "top": -20, "attrs": { "color": "blue" }},
    { "id": "led4", "type": "wokwi-led", "left": 300, "top": -20, "attrs": { "color": "blue" }},
    { "id": "led3", "type": "wokwi-led", "left": 320, "top": -20, "attrs": { "color": "blue" }},
    { "id": "led2", "type": "wokwi-led", "left": 340, "top": -20, "attrs": { "color": "blue" }}


  ],
  "connections": [
    ["uno:GND.1", "led13:C", "black", ["*", "*", "v12", "*"]],
    ["uno:GND.1", "led12:C", "black", ["*", "*", "v12", "*"]],
    ["uno:GND.1", "led11:C", "black", ["*", "*", "v12", "*"]],
    ["uno:GND.1", "led10:C", "black", ["*", "*", "v12", "*"]],
    ["uno:GND.1", "led9:C", "black", ["*", "*", "v12", "*"]],
    ["uno:GND.1", "led8:C", "black", ["*", "*", "v12", "*"]],
    ["uno:GND.1", "led7:C", "black", ["*", "*", "v12", "*"]],
    ["uno:GND.1", "led6:C", "black", ["*", "*", "v12", "*"]],
    ["uno:GND.1", "led5:C", "black", ["*", "*", "v12", "*"]],
    ["uno:GND.1", "led4:C", "black", ["*", "*", "v12", "*"]],
    ["uno:GND.1", "led3:C", "black", ["*", "*", "v12", "*"]],
    ["uno:GND.1", "led2:C", "black", ["*", "*", "v12", "*"]],

    ["r13:1", "led13:A", "red", []],
    ["r12:1", "led12:A", "red", []],
    ["r11:1", "led11:A", "red", []],
    ["r10:1", "led10:A", "red", []],
    ["r9:1", "led9:A", "red", []],
    ["r8:1", "led8:A", "red", []],
    ["r7:1", "led7:A", "red", []],   
    ["r6:1", "led6:A", "red", []],
    ["r5:1", "led5:A", "red", []],
    ["r4:1", "led4:A", "red", []],
    ["r3:1", "led3:A", "red", []],
    ["r2:1", "led2:A", "red", []],

    ["uno:13", "r13:2", "blue", ["*", "*", "*", "*"]],
    ["uno:12", "r12:2", "blue", ["*", "*", "*", "*"]],
    ["uno:11", "r11:2", "blue", ["*", "*", "v10", "*"]],
    ["uno:10", "r10:2", "blue", ["*", "*", "v30", "*"]],
    ["uno:9", "r9:2", "blue", ["*", "*", "v50", "*"]],
    ["uno:8", "r8:2", "blue", ["*", "*", "v70", "*"]],
    ["uno:7", "r7:2", "blue", ["*", "*", "v90", "*"]],
    ["uno:6", "r6:2", "blue", ["*", "*", "v110", "*"]],
    ["uno:5", "r5:2", "blue", ["*", "*", "v130", "*"]],
    ["uno:4", "r4:2", "blue", ["*", "*", "v150", "*"]],
    ["uno:3", "r3:2", "blue", ["*", "*", "v170", "*"]],
    ["uno:2", "r2:2", "blue", ["*", "*", "v190", "*"]]    
  ]
}

Click on the "RUN CODE"

and the chase should begin 👩💻😀👉🤩

Please leave a comment if you need any modifications in the code or for any other doubts. Please also have a look at other interesting Instructables. Your feedback is welcome. Everything is possible due to wokwi Arduino simulator which is a web-based free Arduino simulator. if you also want to contribute, please head to gitHub

Thank you ☘☘🙏

https://www.instructables.com/Best-Free-Online-Wok...

https://www.instructables.com/Web-Based-Arduino-Si...

https://www.instructables.com/Online-Arduino-Simul...

https://www.instructables.com/How-to-Simulate-Ardu...

https://www.instructables.com/Famous-Simon-Says-Ga...

https://www.instructables.com/How-to-Runtest-Your-...