-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathBasic.ino
More file actions
40 lines (32 loc) · 800 Bytes
/
Copy pathBasic.ino
File metadata and controls
40 lines (32 loc) · 800 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
* Basic Countimer example.
*
* Counts down from 10 seconds, prints the remaining time on the serial
* monitor every second and reports when the count is complete.
*/
#include <Countimer.h>
Countimer timer;
void setup()
{
Serial.begin(9600);
// Count down from 00h:00m:10s and call onComplete() when finished.
timer.setCounter(0, 0, 10, timer.COUNT_DOWN, onComplete);
// Call printTime() every 1000 ms while the timer is running.
timer.setInterval(printTime, 1000);
// Nothing happens until the timer is started.
timer.start();
}
void loop()
{
// run() is the heartbeat - it must be called on every loop() iteration.
timer.run();
}
void printTime()
{
Serial.print("Remaining time: ");
Serial.println(timer.getCurrentTime());
}
void onComplete()
{
Serial.println("Complete!");
}