Help needed to create a time test

I am building a sketch that uses an RTC and DHT to control on/off of relays. For relay A, there is only one on/off event per every 24 hours, but relay B I have scheduled for two events per day. Because of this, I am having trouble plotting out the event properly and the result is that the relay only closes the circuit for just a short pulse instead of the desired closed circuit for the time specified. My thought was to include the min and max times into the same test, and have the relay revert to it's default state as set in void setup(), but my test just produces the unwanted pulse.

Here is the snippet I'm having trouble with, and the whole sketch is attached for more detailed inspection. Can someone please show me how to properly word this test so it produces a constant HIGH for 10 minutes before reverting back to LOW?

  if (now.hour() == 9 && now.minute() >= 0 && now.minute() < 10) // FeedPump1, ON 9am
  {  
    digitalWrite(Relay_B, TURN_ON);
    Serial.print("\t");
    Serial.println(F("First 10 Minute Feeding"));  //  Text printed to serial monitor
    Serial.print("\t");
  }
  else // Turn off time for FeedPump1, OFF 9:10am
  {  
    digitalWrite(Relay_B, TURN_OFF);
  }

TYIA

Phase_1.ino (8.89 KB)

but relay B I have scheduled for two events per day. Because of this, I am having trouble plotting out the event properly and the result is that the relay only closes the circuit for just a short pulse instead of the desired closed circuit for the time specified.

You could just pretend that the two different times were for two different events. Then, in the two event handlers, call the same function.

Note that "event handler" does not necessarily mean a function.

Once you turn the pump on, does it really need to be turned on again, and again, and again?

You need to determine when it BECOMES time to turn the pump on. When it does, turn it on. It can't BECOME the right time again while the pump is on, unless the pump needs to be on for more than 24 hours.

PaulS:
You could just pretend that the two different times were for two different events. Then, in the two event handlers, call the same function.

Note that "event handler" does not necessarily mean a function.

Once you turn the pump on, does it really need to be turned on again, and again, and again?

You need to determine when it BECOMES time to turn the pump on. When it does, turn it on. It can't BECOME the right time again while the pump is on, unless the pump needs to be on for more than 24 hours.

Thanks Paul. The solution was to create a boolean to queue the days events respective of a specific digital pin. I had to discontinue individualized serial messages and use a boilerplate message for all events dealing with that pin.

//*********************************** FEED TIMEs - RELAY_B ******************************************//
  // By testing hour once and minute twice, we isolate the "on" time and the duration it is "on". *****//
  // If the Boolean becomes true, D31 is HIGH until Boolean becomes false again. **********************//
  boolean relayBstate = false;
  if (now.hour() == 9 && now.minute() >= 0 && now.minute() < 10) relayBstate = true;    //9:00 am - 10mins
  if (now.hour() == 15 && now.minute() >= 30 && now.minute() < 40) relayBstate = true;  //3:30 pm - 10mins
  if (now.hour() == 22 && now.minute() >= 30 && now.minute() < 33) relayBstate = true;  //10:30pm - 03mins
  if (relayBstate == true)
  {  
    digitalWrite(Relay_B, TURN_ON);
    Serial.print("\t");
    Serial.println(F("Feeding Plants"));  //  Text printed to serial monitor
    Serial.print("\t");
  }
  else
  {  
    digitalWrite(Relay_B, TURN_OFF);
  }

Also, careful inspection revealed an extra set of curly braces in the loop. I don't understand why it even compiled and ran.