Code to turn on relay in some time

Hey, Im noob at this, but basically the code should turn on relay in the set time. For some reason, the IF function which checks time works, but only until you dont get to ((now.minute(), DEC) < minDO1)

No matter what I did, the last statement or whatever you call it ((now.minute(), DEC) < minDO1), just doesnt work! I noticed that it does something, when there is < the relay is turned OFF(always), when there is <=, the relay is turned on (AT ALL TIMES!!(no matter the minDO1 number))

So basically, it works if I only want to check the hour and if now time >= set time, but < or <= doesnt work

btw yeah it has some copied stuff from other sample projects because as I said its my first time with D1307 rtc module and also the code also shows you the time and if the time interval has been activated (is true)

CODE:

#include <Wire.h>
#include "RTClib.h"

/////////////////////////////////////////////////////////////////////////////////////////


//    HOUR                          From minute                To minute

//  1.
int hodOD1 = 20;             int minOD1 = 41;         int minDO1 = 45;

///////////////////////////////////////////////////////////////////////////////////////////


RTC_DS1307 rtc;

char daysOfTheWeek[7][12] = {"Sunday","Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};

int relay = 9;

#if defined(ARDUINO_ARCH_SAMD)
// for Zero, output on USB Serial console, remove line below if using programming port to program the Zero!
   #define Serial SerialUSB
#endif

void setup () {
Serial.begin(57600);
if (! rtc.begin()) {
    Serial.println("Couldn't find RTC");
    while (1);
    }
    
#ifndef ESP8266
  while (!Serial); // for Leonardo/Micro/Zero
#endif

pinMode(relay, OUTPUT);
digitalWrite(relay, HIGH);
  }

void loop () {
    DateTime now = rtc.now();
    Serial.print(now.hour());
    Serial.print(now.minute());
    Serial.println();
// 1.      
if(now.hour() == hodOD1 && now.minute() >= minOD1 && now.minute() <= minDO1 ){
  digitalWrite(relay, LOW);
  Serial.print("xxxx");
  }
  else{
    digitalWrite(relay,HIGH);
    }      
}

if(((now.hour(), DEC) == (hodOD1, DEC))  && ((now.minute(), DEC) < (minDO1, DEC))){Can you explain what you think all those "DEC"s are doing?

What I think? I think Arduino receives the time from D1307 in decimal numbers or somtehing like that, Im not sure, but there needs to be DEC in both the now.minute and minDO1, otherwise it just doesnt work, I think it somehow converts to decimal or something like that

(got it from RTClib ds1307 sample project)

please check the if statement again, there was a mistake in copying

motorko:
please check the if statement again, there was a mistake in copying

Still nonsense.

You could have added the code tags when you were editing the post.

Look at your if-statement

if(now.hour() == hodOD1 && now.minute() > minOD1 && now.minute() < minOD1 ){
:
}

What is the value of minOD1?
Can it be greater than now.minute() and less than now.minute() at the same time?

Thank you :DD, I fixed my problem, but it wasnt only because of minOD1 two times in a row mistake, it was a compilation of other errors.

Basically, Ive firstly removed all the DEC things at both the now.hour(), DEC and for 20, DEC, it worked, there also needs to be this line of code

if (! rtc.begin()) {
    Serial.println("Couldn't find RTC");
    while (1);
    }

else the rtc module gives you constant time of 2165 165 85 etc…(and all those serial things and stuff…)
And then, when it worked, I made this stupid mistake that you pointed out, but now it works as its supposed to, here is the full working code

#include <Wire.h>
#include "RTClib.h"

/////////////////////////////////////////////////////////////////////////////////////////


//     HOUR                             FROM MINUTE        TO MINUTE

//  1.
int hodOD1 = 16;           int minOD1 = 14;         int minDO1 = 40;

//  2.     
int hodOD2 = 23;           int minOD2 = 30;         int minDO2 = 50;

//  3.    
int hodOD3 = 1;           int minOD3 = 0;         int minDO3 = 20;

//  4.   
int hodOD4 = 2;           int minOD4 = 30;         int minDO4 = 50;

//  5.   
int hodOD5 = 4;           int minOD5 = 0;         int minDO5 = 20;

///////////////////////////////////////////////////////////////////////////////////////////


RTC_DS1307 rtc;

char daysOfTheWeek[7][12] = {"Sunday","Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};

int relay = 9;
int disable = 0;

#if defined(ARDUINO_ARCH_SAMD)
// for Zero, output on USB Serial console, remove line below if using programming port to program the Zero!
   #define Serial SerialUSB
#endif

void setup () {
Serial.begin(57600);
if (! rtc.begin()) {
    Serial.println("Couldn't find RTC");
    while (1);
    }
    
#ifndef ESP8266
  while (!Serial); // for Leonardo/Micro/Zero
#endif

pinMode(relay, OUTPUT);
digitalWrite(relay, HIGH);
  }

void loop () {
  disable = 0;
    DateTime now = rtc.now();
    Serial.print(now.hour());
    Serial.print(now.minute());
    Serial.println();
    
// 1.      
if(now.hour() == hodOD1 && now.minute() > minOD1 && now.minute() < minDO1 ){digitalWrite(relay, LOW);Serial.print("xxxx");}else{disable = disable + 1;}
    
// 2.      
if(now.hour() == hodOD2 && now.minute() > minOD2 && now.minute() < minDO2 ){digitalWrite(relay, LOW);Serial.print("xxxx");}else{disable = disable + 1;}
    
// 3.      
if(now.hour() == hodOD3 && now.minute() > minOD3 && now.minute() < minDO3 ){digitalWrite(relay, LOW);Serial.print("xxxx");}else{disable = disable + 1;}
    
// 4.      
if(now.hour() == hodOD4 && now.minute() > minOD4 && now.minute() < minDO4 ){digitalWrite(relay, LOW);Serial.print("xxxx");}else{disable = disable + 1;}
    
// 5.      
if(now.hour() == hodOD5 && now.minute() > minOD5 && now.minute() < minDO5 ){digitalWrite(relay, LOW);Serial.print("xxxx");}else{disable = disable + 1;}




if (disable == 5) {
  digitalWrite(relay, HIGH);
  }    
}