const int ledPin = LED_BUILTIN;
int ledState = LOW;
unsigned long previousMillis = 0;
const long interval = 1000;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
}
void loop() {
// pu t your main code here, to run repeatedly:
unsigned long currentMillis = millis();
if(currentMillis-previousMillis>=interval){
previousMillis = currentMillis ;
if(ledState == LOW){
ledState = HIGH;
}else{
ledState = LOW;
}
Serial.print("Current :");
Serial.println(currentMillis);
Serial.print("Previous :");
Serial.println(previousMillis);
digitalWrite(ledPin,ledState);
}
}