-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCountdown.ino
More file actions
36 lines (28 loc) · 729 Bytes
/
Copy pathCountdown.ino
File metadata and controls
36 lines (28 loc) · 729 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
#include <SoftTimers.h>
#define LED_PIN 13
/**************************************************
* Run a countdown from 5 second to 0 and turn LED on
**************************************************/
SoftTimer countdown; //millisecond timer
void setup() {
pinMode(LED_PIN, OUTPUT);
Serial.begin(115200);
//update timers
countdown.setTimeOutTime(5000); // 5 seconds
//start counting now
countdown.reset();
}
void loop() {
if (!countdown.hasTimedOut())
{
//show user how much time left in milliseconds
unsigned long remaining = countdown.getRemainingTime();
Serial.print(remaining);
Serial.println(" ms...");
}
else
{
//turn ON the LED
digitalWrite(LED_PIN, HIGH);
}
}