This was my code for triggering the IF statement. Please help guysss. I wanted to trigger and use the IF statement forever if the time already hits the required time. Thank youu!
#include <DS3231.h>
DS3231 rtc(SDA, SCL);
int Light = 1;
void setup()
{
Serial.begin(115200);
rtc.begin();
pinMode(Light, OUTPUT);
//The following lines can be uncommented to set the date and time
//rtc.setDOW(WEDNESDAY); // Set Day-of-Week to SUNDAY
//rtc.setTime(13, 30, 50); // Set the time to 12:00:00 (24hr format)
//rtc.setDate(1, 1, 2014); // Set the date to January 1st, 2014
}
void loop()
{
String TIME = rtc.getTimeStr();
//NOTE! For example my time now is 13:30:50.
if (TIME ?? What do i put here?) //If the time already hits 20:00:00 and so on. I want to use the function inside the IF, forever. By means that. The light will be ON forever.
{
digitalWrite(Light, LOW); //ON
}
else //If the time does not still hit 20:00:00 it will do this function.
{
digitalWrite(Light, LOW); //ON
delay(1000);
digitalWrite(Light, HIGH); //OFF
delay(1000);
}
Serial.print(rtc.getDOWStr());
Serial.print(" ");
Serial.print(rtc.getDateStr());
Serial.print(" -- ");
Serial.println(rtc.getTimeStr());
delay (1000);
}