Arduino millis();

is there a way to reset millis(), without rebooting arduino and without waiting for 8+ hours ??

thanks in advance

newMillis() {

return (millis() - bias);

}

resetMillis() {

bias = millis();

}

this would work only if millis haven’t been reset, cause let say the upper limit for millis is roughly 4,000,000,000

and i call the new reset millis at millis = 3,900,000,000

and then new millis after a while, i get something like:

(millis = 10,000) 10,000 - 3,900,000,000 = newmillis

which is not good.

thanks for the help anyway !

So what is 10,000 - 3,900,000,000?

In human numbering that is -3,899,990,0000

But using a long unsigned integer that is actually 394,977,296. And that is the correct answer for the number of milliseconds between when you reset the timer at 3.9E9 and when the counter read 10,000. The only time this would fall apart is if you do not reset the counter at least once every 50 days.

Edit: Better example: You reset the counter 5 counts before the maximum

Max = 2^32-1 = 4,294,967,295

bias = Max-5 = 4,294,967,290

1 ms later millis() = 4,294,967,291

2 ms later millis() = 4,294,967,292

3 ms later millis() = 4,294,967,293

4 ms later millis() = 4,294,967,294

5 ms later millis() = 4,294,967,295

6 ms later millis() = 0

7 ms later millis() = 1

8 ms later millis() = 2

9 ms later millis() = 3

10 ms later millis() = 4

If you call newMillis at +10ms you would compute 4-bias or 4-4,294,967,290 or (drum roll please…) 10!