#define LED_PIN 2
unsigned long previousMillis = 0;
const long interval = 1000; // Blink interval (ms)
bool ledState = LOW;
void setup() {
pinMode(LED_PIN, OUTPUT);
}
void loop() {
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval) {
previousMillis = currentMillis;
ledState = !ledState; // Toggle state
digitalWrite(LED_PIN, ledState); // Update LED
}
// Other tasks can run here without being blocked by delay()
}