int del = 100; //defining delay value (0.1 second)
void setup() {
// put your setup code here, to run once:
pinMode(2, OUTPUT); //defining pins (2-13) as Outputs
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
pinMode(12, OUTPUT);
pinMode(13, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
for (int i = 2; i <= 13; i++) { // For loop will count from 2 to 13 to turn ON and OFF every single pin
digitalWrite(i, HIGH); // Turning ON 1st output (LED)
delay(del); // LED is ON for 20ms before turning OFF
digitalWrite(i, LOW); // Turning OFF 1st output (LED)
delay(del); // Waiting 20ms before running the 2nd cycle of FOR loop
}
for (int i = 13; i >= 2; i--) { // For loop will count from 13 to 2 to turn ON and OFF every single pin
digitalWrite(i, HIGH); // Turning ON 1st output (LED)
delay(del); // LED is ON for 20ms before turning OFF
digitalWrite(i, LOW); // Turning OFF 1st output (LED)
delay(del); // Waiting 20ms before running the 2nd cycle of FOR loop
}
}