int timer = 600; // Cycle Timing
int pins[] = {7, 8, 9, 10, 11, 12 }; // An array of I/Os
int num_pins = 6; // The number of I/Os
void setup() {
{
int i;
for (i = 0; i < num_pins; i++)
// The array elements are numbered from 0 to num_pins - 1
pinMode(pins[i], OUTPUT); // Set each I/O as an output
}
}
void loop() {
{
int i;
for (i = 0; i < num_pins/2; i++) { // Loop through each pin state
digitalWrite(pins[i], HIGH); // Turn ON one LED
digitalWrite(pins[i+num_pins/2], HIGH); //Then turn OFF its opposite LED
//Now turn the previous LEDs OFF
if (i == 0){ //Turn OFF the last LED from the previous go around
digitalWrite(pins[num_pins-1], LOW);
} else{
digitalWrite(pins[i-1], LOW); // Turn OFF each previous LED
}
digitalWrite(pins[(i+num_pins/2)-1], LOW);
delay(timer); // Halt for a while!
}
}
}