(Im a beginner in Arduino)
This is my first ever code I wrote. Im using a DS3231 for time and I have for the moment, one relay that i need to program so it turns on a certain time. I already have the timing set and figured out, but im having a problem when the relay is set LOW i need the arduino to stay in a infinite loop until it reaches 3pm everyday.
below is the code for the timing and relays, let me know if i have made any mistakes or anything i can do to fix it.
{t = rtc.getTime();
Serial.print(t.hour);
Serial.print(" hour(s), ");
Serial.print(t.min);
Serial.print(" minute(s), ");
Serial.print(t.sec);
Serial.print(" sec(s)");
Serial.println(" ");
delay(1000);
if(t.hour > OffHour && t.hour < OffHour2 && t.min >= OffMin && t.sec >= OffSec){
digitalWrite(Relay,LOW);
Serial.println("LIGHT OFF");
return loop();} //return to the top if not on the hour
//loop();}//return to the top if not on the hour
else if(t.hour == OnHour && t.min == OnMin && t.sec >= OnSec){
digitalWrite(Relay,HIGH);
Serial.println("LIGHT ON");}}//continue with the counter