int ledPin[] = {13, 12, 11,10};
int ledDelay[4]={8000, 4000,2000, 1000};
// declare other required variables
unsigned long lastChangeTime[4];
bool ledState[4];
unsigned long currTime;// Variable to store the current time
void setup() {
currTime =0;
for(int i=0;i<4;i++)
{
pinMode(ledPin[i], OUTPUT);// set pin mode for ledPins
lastChangeTime[i] = 0;// initialize lastChangeTimes
ledState[i] = LOW; // Initialize LED state to LOW
digitalWrite(ledPin[i], ledState[i]); // Ensure LEDs start in the LOW state
}
}
void loop() {
// implement the toggling logic
currTime = millis();
// Toggle each LED based on its delay interval
for (int i = 0; i < 4; i++) {
if (currTime - lastChangeTime[i] >= ledDelay[i]) {
lastChangeTime[i] = currTime; // Update the last change time
ledState[i] = !ledState[i]; // Toggle the LED state
digitalWrite(ledPin[i], ledState[i]); // Apply the new state to the LED
}
}
}