After having a need to execute Arduino functions that run periodically, Balázs Kelemen created the “arduino-softtimer” library to help do just that. In his words:
SoftTimer class is a Timer Manager that constantly scans the registered task if it is time to run it. If so (launch start time is passed) the callback is launched. No matter how long the callback is running, the next run will be scheduled according to the previous start time. The period of starting is defined at the Task. The period of the task may be changed if necessary.
This creates interesting new options with regards to coding style, for example creating state machines or object-oriented programming. Timing is measured in milliseconds so you can a fait amount of accuracy, and setting it up in your sketch is made simple with the well documented instructions. Like most other libraries it’s a work in progress, however could be useful even now depending on your application.
For more information visit the softtimer project page. And for more, we’re on twitter and Google+, so follow us for news and product updates as well.
If you’re interesting in other types of timing – such as real-time clocks, check out our Maxim DS3232 real-time clock IC module:
Apart from keeping accurate time for years due to the temperature-controlled oscillator and having a tiny coin-cell for backup, it is very simple to connect to your Arduino project. A driver library allows your program to easily set or read the time and date. Perfect for clock projects, dataloggers or anything that needs to know the date and time. Furthermore it contains a digital thermometer and 236 bytes of non-volatile memory to store user settings and other data. For more information, check out the module page here.