Arduino: Using millis() Instead of delay() - DZone IoT

PHOTO EMBED

Sat Apr 16 2022 15:57:04 GMT+0000 (Coordinated Universal Time)

Saved by @ehraz786 #c++

int period = 1000;
unsigned long time_now = 0;

void setup() {
    Serial.begin(115200);
}

void loop() {
    if(millis() > time_now + period){
        time_now = millis();
        Serial.println("Hello");
    }

    //Run other code
}
content_copyCOPY

millis()

https://dzone.com/articles/arduino-using-millis-instead-of-delay