Compare times

UKHeliBob:

  if ((now.hour() <= 10 ) && (now.hour() > 13 ))

You have done it again.

now.hour() cannot be equal or less than 10 and greater than 13

It could be equal or less than 10 or greater than 13 though

See reply #4

Hi UKHeliBob

Thank you for your Support

I understand that at the same (if) I can not make two comparisons with (now.hour ()) right?
I already did several searches but I did not find anything that helps me.
No (reply # 4) already said that I do not know how to implement the code for the 17:59 time
I changed the code again in two (if) but without success!

Hope it helps

#include <Wire.h>
#include "RTClib.h"
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 20, 4);
RTC_DS3231 RTC;

//#define in1 3 // 
//#define val_d  4   // 

byte hour1 = 0;
byte min1 = 0;
byte seg1 = 0;


String zero(int n) { 

  if (n < 10) {     
    return "0" + String(n);       
  } else {
    return String(n);
  }
}
void setup () {
  lcd.backlight();
  lcd.init();
  Wire.begin();
  RTC.begin();
  // RTC.adjust(DateTime(2017,11,5, 3, 0, 0));

  //RTC.adjust(DateTime(__DATE__, __TIME__));
  //pinMode(in1, INPUT);
  //pinMode(val_d, INPUT);
}

void loop () {

  DateTime now = RTC.now();
  hour1 = (now.hour(), DEC);
  min1 = (now.minute(), DEC);
  seg1 = (now.second(), DEC);

  lcd.setCursor(0, 0);
  lcd.print(zero(now.day()));
  lcd.print('/');

  lcd.print(zero(now.month()));
  lcd.print('/');
 
  lcd.print(now.year(), DEC);
  lcd.print(' ');
  
  lcd.setCursor(0, 1);
  lcd.print(zero(now.hour()));
  lcd.print(':');

  lcd.print(zero(now.minute()));
  lcd.print(':');

  lcd.print(zero(now.second()));

 
      if (now.hour() > 10 ) // 
      {
        if(now.hour() < 12 )
        {
        lcd.setCursor(5, 3);
        lcd.print("Open window");
        delay(30);
        }
      }
         if (now.hour() < 10 ) // 
         {
        if(now.hour() > 12 )
        {
        lcd.setCursor(5, 3);
        lcd.print("Closed window");
        delay(30);
        }
      }
}