Timing Functions

System Time: millis() & micros()

You can get the total time since your program started, in milliseconds using millis(), or in microseconds using micros().

These return a number between 0 to 4294967295. When they reach the maximum, they roll back over to 0. For millis, that's approximately 49.7 days. For micros, that's 1 hour, 11 minutes, 34.967295 seconds. When computing time differences, care should be taken to handle the roll over case. An example can be found in File > Examples > 2.Digital > BlinkWithoutDelay.

Internally, elapsedMillis and elapsedMicros use millis and micros. They handle roll over automatically, and are much easier to use.

TODO: add some examples

TODO: section about getting the math right, #1: 32 bit unsigned long, #2: handling rollover