About function millis()

Hello all,
Is the delay() function stop the millis() function or the millis() continuously working all the time

Millis and micros work through Timer and interruptions so will continue counting during delay

You can type, you can test this yourself!

Nice for your point
Thank you Sr

yes, but I have bigger duration so I can not knows.
Also, the millis() running fast

you could do something like this to prove the point to yourself:

void setup() {
  Serial.begin(115200);
  unsigned long t0 = millis();
  delay(3000);
  unsigned long t1 = millis();
  Serial.print("\nt0="); Serial.println(t0);
  Serial.print("t1="); Serial.println(t1);
}

void loop() {}

look at the Serial monitor (at 115200 bauds)
if milllis() is not counting during delay, t0 and t1 would be very close.
if millis() is counting, then the difference between t1 and t0 should be very close to 3s (3000ms)

➜ run the test

Do you mean that it is running faster than you expect ?

No Sr bur the serial printed the numbers in a fast way

Thanks Sr

I guess it was not that fast after all :slight_smile: