Delay vs Timer vs Millis - Solved

When done right that's no issue since unsigned calculations don't care for the roll-over.
The result of (smallUnsignedNumber - bigUnsignedNumber) will not give you a negative but the expected difference as if you had an extra bit allowing the "smallUnsignedNumber" count past the roll-over limit.

That's why you often see code like this

  if (millis() - msLastPublish < period) doNothing();

See here

4 Likes