myggle:
However, when I get to my second alarm, I fear my knowledge of the code is failing me and keeping me from asking the right question(s) of the RTC.
Perhaps use the IPO principle and do a logical seperation of:
- Input
- Processing
- Output
Do not try to mix input with just a small part of the processing logic and then output directly before all processing is done.
For your relay switching I'd suggest a programming logic like that looping around in the loop() function (untested code):
// Input ==> read the current time from RTC
// Processing
boolean relayBstate=false; // initial guess is "relay B is OFF"
if (now.hour() == 9 && now.minute() >= 00 && now.minute() < 10) relayBstate=true; // 1st 'ON' time
if (now.hour() == 12 && now.minute() >= 00 && now.minute() < 10) relayBstate=true; // 2nd 'ON' time
if (now.hour() == 15 && now.minute() >= 00 && now.minute() < 10) relayBstate=true; // 3nd 'ON' time
// Output
if (relayBstate==true)
{
if (digitalRead(Relay_B)!=TURN_ON) Serial.println("Turn ON relay B");
digitalWrite(Relay_B, TURN_ON);
}
else
{
if (digitalRead(Relay_B)!=TURN_OFF) Serial.println("Turn OFF relay B");
digitalWrite(Relay_B, TURN_OFF);
}