Untested. See if you can run your finger through this to see how it works. And if it does what you want.
void printDateTime()
{
Serial.print(RTC.dayofmonth);
Serial.print("/");
Serial.print(RTC.month);
Serial.print("/");
Serial.print(RTC.year);
Serial.print(" ");
Serial.print(RTC.hours);
Serial.print(":");
Serial.print(RTC.minutes);
Serial.print(":");
Serial.println(RTC.seconds);
}
int printStatus() {
static int flag = 0;
if (Level <= 200) {
if (flag != -1) {
printDateTime();
Serial.println("Signal OFF ");
}
flag = -1;
}
else { // Level > 200
if (flag != 1) {
printDateTime();
Serial.println("Signal ON ");
}
flag = 1;
}
}
Sry, I don't usually like to hand you a fish. So do take a look. Just one of as many ways to do this as there are programmers, approximately. ![]()
It may print more than you want. You could code some hysteresis in there like your home thermostat employs so the A/C not be going on and off alla time.
a7