I’m working on this code. I want a count down tool that See his countdown timer time form a variable that is lookup when the counter starts…
How do I build this<<<
/*
* Open serial monitor, press one of the keys below and click 'Send':
* 'S' - Start timer
* 'P' - Pause timer
* 'R' - Restart timer
* 'T' - Stop timer
*/
#include "Countimer.h"
Countimer TIMER;
int CounterStatus = 0;
int CounterStatus1x = 0;
void setup()
{
Serial.begin(9600);
// HELP >>>> Count-down Need to run form a variable and (re)set later
TIMER.setCounter( 0, 0, 21, TIMER.COUNT_DOWN, TIMERComplete);
// Call print_time2() method every 1s.
TIMER.setInterval(print_time2, 1000);
Serial.println("Online");
}
void loop()
{
TIMER.run();
if (Serial.available() > 0)
{
char c = toupper(Serial.read());
switch (c)
{
case 'T':
TIMER.stop();
break;
case 'R':
TIMER.restart();
break;
case 'S':
TIMER.start();
CounterStatus = 1;
CounterStatus1x = 1;
break;
case 'P':
TIMER.pause();
break;
default:
break;
}
}
if (CounterStatus == 0 && CounterStatus1x == 0) {
Serial.print("OFF \n");
CounterStatus1x = 1;
}
}
void print_time2()
{
Serial.print("Tijd: ");
Serial.println(TIMER.getCurrentTime());
}
void TIMERComplete()
{
digitalWrite(13, LOW);
CounterStatus = 0;
CounterStatus1x = 0;
}