int ledPin[] = {13, 12, 11,10};
int ledDelay[4]={8000, 4000,2000, 1000};
// declare other required variables
unsigned long lastChangeTimes[4] = {0, 0, 0, 0};
int ledStates[4] = {LOW, LOW, LOW, LOW};
unsigned long currTime = 0;
void setup() {
currTime =0;
for(int i=0;i<4;i++){
// initialize lastChangeTimes
lastChangeTimes[i] = currTime;
// set pin mode for ledPins
pinMode(ledPin[i], OUTPUT);
digitalWrite(ledPin[i], ledStates[i]);
}
}
void loop() {
// implement the toggling logic
currTime = millis();
for(int i = 0; i < 4; i++) {
if(currTime - lastChangeTimes[i] >= ledDelay[i]) {
lastChangeTimes[i] = currTime;
ledStates[i] = !ledStates[i];
digitalWrite(ledPin[i], ledStates[i]);
}
}
}