Arduino Project: Walking LED lights

Project Details

This Arduino project is very simple. We have 4 LEDS with turn ON and OFF after one another showing to be walking dot. 

It turns ON each LED, keeps it ON for certain time and then turns it OFF.  We have on time defined in onTime variable and off time defined in offTime variable.  Just copy and paste the code and connect the LEDs as shown in diagram. 

Project Images
Image

 

 

Project Code

/*
 * LED = Light Emitting Diode
 * LED is pronouced (El EE Dee)
 * 4 LEDS walking light Arduio Project
 * this is an Arduino sktech where 4 LEDS turn ON and OFF in such a way
 * that an LED is walking
 * 
 * written by Ahmad Shamshiri on Oct 27, 2021 at 16:46 in Ajax, Ontario, Canada
 * this code can be obtained from Robojax.com
 * Code ID: WalkingLED
 */
int offTime = 1;//the time LED waits in OFF state
int onTime = 300;//the time LED is ON 

//the code inside setup() runs once.

void setup() {
  pinMode(2, OUTPUT);//set pin 2 of Arduino as output
  pinMode(3, OUTPUT);//set pin 3 of Arduino as output
  pinMode(4, OUTPUT);//set pin 4 of Arduino as output
  pinMode(5, OUTPUT);//set pin 5 of Arduino as output
}//setup end

void loop() {
  
  digitalWrite(2, HIGH);//set pin 2 to HIGH 
  delay(onTime);    //wait for the onTime seconds (see top of this code)                   
  digitalWrite(2, LOW); // Set pin 2 to LOW
  delay(offTime);  //wait for the offTime seconds (see top of this code) 

  digitalWrite(3, HIGH);  //set pin 3 to HIGH 
  delay(onTime);      //wait for the onTime seconds (see top of this code)                    
  digitalWrite(3, LOW); // Set pin 3 to LOW  
  delay(offTime);  //wait for the offTime seconds (see top of this code)    

  digitalWrite(4, HIGH); //set pin 4 to HIGH  
  delay(onTime);     //wait for the onTime seconds (see top of this code)                     
  digitalWrite(4, LOW); // Set pin 4 to LOW  
  delay(offTime);   //wait for the offTime seconds (see top of this code)   

  digitalWrite(5, HIGH);  //set pin 5 to HIGH 
  delay(onTime);    //wait for the onTime seconds (see top of this code)                      
  digitalWrite(5, LOW);  // Set pin 5 to LOW 
  delay(offTime);    //wait for the offTime seconds (see top of this code)                               
}

 

If you found this Arduino course helpful, please support me so I can continue creating content like this. support me via PayPal