Friday, 14 September 2012

Interval Handling on Arduino

When designing devices which never reset and which need to be aware of time, one thing to beware of is the millisecond timer rolling over. According to the reference manual, this happens after about 50 days. If your device is designed to be powered on for short periods of time and happens to be on while this timer overflows, then it will fail to power off and you'll have to power-cycle it.
This little class avoids this problem by watching for the overflow and calculating the interval correctly.

No comments:

Post a Comment