int ledPin = 2; unsigned long previousMillis = 0; // Store the time of the last LED toggle void setup() { pinMode(ledPin, OUTPUT); // Set the LED pin as an output } void loop() { unsigned long currentMillis = millis(); // Get the current time if (currentMillis - previousMillis < 500) { digitalWrite(ledPin, HIGH); Serial.println("LED is ON"); Serial.println("LED is ON"); Serial.println("LED is ON"); } else if (currentMillis - previousMillis < 1000) { digitalWrite(ledPin, LOW); Serial.println("LED is OFF"); Serial.println("LED is OFF"); Serial.println("LED is OFF"); } else{ previousMillis = currentMillis; } }