Time controlled light

I have started Arduino based aquarium controller. At the moment I got stuck with the time controlled outputs. I am sorry for my English but I’ll try to explain.
I am working on Arduino PRO MINI. Also using Tiny RTC DS1307 and I2C 20x4 LCD booth on the same I2C line. For RTC I am using RTClib.h librarry. Dallas temperature sensor, DH11. Everything is working good but time control. I have time on display, I can adjust time by 3 buttons.
I want to control aquarium light, air pump, 2 filters by time. For instance: I want that aquarium lights could light on right on 7.30 and turns off on 21.30. Nearly the same with other stuff (filters, air etc.) The important thing is that after power failure during ON time (day time) controller should turn on light again when power comes on again.

Here is part of my code for time controller:

//define
unsigned int LightStartHr = 7; // light on hour
unsigned int LightStartMin = 30; // light on minute

unsigned int LightEndHr = 21; // light off hour
unsigned int LightEndMin = 30; // light of minute

void loop()
   {
      if ((hours >= LightStartHr && minutes >= LightStartMin) && (hours <= LightEndHr && minutes < LightEndMin))
      { 
        // turn on light
        lcd.setCursor(0, 3);
        digitalWrite(LightLED, HIGH);
        digitalWrite(NightLED, LOW);
        lcd.print("Day "); 
      
      }
    else
    {
      
   // turn off light
        lcd.setCursor(0, 3);
        digitalWrite(LightLED, LOW);
        digitalWrite(NightLED, HIGH);
        lcd.print("Night");
      }  
    }

I hope this helps you to understand what I want and figure out my mistake.
I must tell you that if I remove minutes and stay with only hours - everything is working fine. Light is turning on in round about hour set. The same if I remove hour and stay only with minutes. How to force controlling with booth hour and minute: “if ((hours >= LightStartHr && minutes >= LightStartMin) && (hours <= LightEndHr && minutes < LightEndMin))”
I am not good in Arduino programming :~ so I need support here.
By the way I have searched a lot unsuccessfully. A lot of examples are based on mills. They counting time from midnight. This is not good for me. I want control outputs by 24H time. Thanks.

I hope this helps you to understand what I want and figure out my mistake.

No, it doesn't, because hours and minutes are undefined and never valued.

Work in minutes since midnight for your comparisons. Your issue now is that you're testing for minutes to be greater or equal to 30 and less than 30 - not likely to happen.

This doesn't do what you want...

(hours >= LightStartHr && minutes >= LightStartMin)

At 7:30 this will evaluate to true and then evaluate to false at 8:00. So every half hour the expression will change value.

OK guys I am totally confused. If I have simple values of time from RTC (from 00.00 to 23.59) I expect an option to trigger on something at the specific time and switch it of also at the specific time. And now you are telling me that this is not possible... As I have said I am not good in English so might be I misunderstood you even if I read your answers a lot of times. Guys can you explain me in more simple manner that even me could understood :disappointed_relieved: because I really do not believe that this is not possible. Thanks.

Barcors:
OK guys I am totally confused. If I have simple values of time from RTC (from 00.00 to 23.59) I expect an option to trigger on something at the specific time and switch it of also at the specific time. And now you are telling me that this is not possible…

No, they are telling you that your code cannot work, and why it will not work. To be more specific, here’s why…

(hours >= LightStartHr && minutes >= LightStartMin)

This will be true between 7:30 and 7:59
It will be false between 8:00 and 8:29
It will be true again between 8:30 and 8:59
That pattern will continue until 23:59

(hours <= LightEndHr && minutes < LightEndMin)

This will be true between 0:00 and 0:29
It will be false between 0:30 and 8:59
It will be true again between 1:00 and 1:29
That pattern will continue until 21:59

So, look at the entire statement.

If it’s 7:30, the first part will be true, and the second part will be false
so:
true && false gives you false, so your lights will never come on.

Then look at 21:30
The first part will be false and the second part will be true
false && true gives you false, so the lights, if on, will never turn off.

You should make one time variable, and set it to the minutes since midnight, then check to see that your time is during the desired ON time.

int timeSinceMidnight;
int onTime = 450;    // 7 * 60 + 30
int offTime = 1290;  // 21 * 60 + 30

Then, in loop()
  //read the time.
  timeSinceMidnight = (hours * 60) + minutes;
  if ( (timeSinceMidnight >= onTime) && (timeSinceMidnight < offTime) ) {
    //turn lights on
  }
 else {
   //turn lights off
  }

This also fits your requirement that the lights come on after the power is restored, if it’s during the ON lime.

Huge thank you dear lar3ry. And thank you all of you guys. I am sorry for my stupidity but as I have said I am just the beginner. Lar3ry I will try to add code you suggested and we will see if it works. But anyway I cant believe that this should be complicated like this. You see I am thinking simple: if I have time from RTC all the time so I should tell to program only to look at that time and when it will come to time I need it trigger something to do. But now from code you suggested I see that processor should count minutes since midnight and do something after pass minutes needed. Huh this is something. Anyway if it no more simple way I will try lar3ry code. Thank you again guys.