/*
* [Link]
*
* Based on usage example for Time + TimeAlarm libraries
*
* A timer is called every 15 seconds
* Another timer is called once only after 10 seconds
* A third timer is called 10 times.
*
*/
#include <SimpleTimer.h>
// There must be one global SimpleTimer object.
// More SimpleTimer objects can be created and run,
// although there is little point in doing so.
SimpleTimer timer;
// function to be called repeatedly
void RepeatTask() {
[Link]("15 second timer");
}
// function to be called just once
void OnceOnlyTask() {
[Link]("This timer only triggers once");
}
// function to be called exactly 10 times
void TenTimesTask() {
static int k = 0;
k++;
[Link]("called ");
[Link](k);
[Link](" / 10 times.");
}
// print current arduino "uptime" on the serial port
void DigitalClockDisplay() {
int h,m,s;
s = millis() / 1000;
m = s / 60;
h = s / 3600;
s = s - m * 60;
m = m - h * 60;
[Link](h);
printDigits(m);
printDigits(s);
[Link]();
}
//
// utility function for digital clock display:
// prints preceding colon and leading 0
//
void printDigits(int digits) {
[Link](":");
if(digits < 10)
[Link]('0');
[Link](digits);
}
void setup() {
[Link](9600);
// welcome message
[Link]("SimpleTimer Example");
[Link]("One timer is triggered every 15 seconds");
[Link]("Another timer is set to trigger only once after 10 seconds");
[Link]("Another timer is set to trigger 10 times");
[Link]();
// timed actions setup
[Link](15000, RepeatTask);
[Link](10000, OnceOnlyTask);
[Link](1000, DigitalClockDisplay);
[Link](1200, TenTimesTask, 10);
}
void loop() {
// this is where the "polling" occurs
[Link]();
}