Any ideas how to make "if" statment more simple?

Okay, the problem is if statment gets to long

I'm making watering automation and i have little problem about days

I have 7 days on lcd if it's 1 lcd prints name of the day else its "--"
So i have 7 split numbers on lcd

What i need: i started to compare functions with RTC clock
With time it's fine
But when i came to day selections I just have to many vars
I mean i could write everything down, but it must be more clever way to do that, so I ask you The smartest arduinoheads in the world :slight_smile:

int daystate;


void FUNC_COMPARE_Timer_WeekDay() {
  if (EEday0 >=1){
    daystate == 0;
  }
    else if( EEday1 >= 1){
      daystate == 1;
    }
    else if (EEday2 >= 1) {
      daystate == 2;
    }
     else if( EEday3 >= 1){
      daystate == 3;
    }
    else if (EEday4 >= 1) {
      daystate == 4;
    }
     else if( EEday5 >= 1){
      daystate == 5;
    }
    else if (EEday6 >= 1) {
      daystate == 6;
    }
    Serial.print(daystate);
  
   
  
  DateTime now = rtc.now();
  
  if (EEhour == now.hour() && EEminute == now.minute()) && daystate == now.dayOfTheWeek) {
    digitalWrite(valve1, HIGH);
  }
  else if (EEhour1 == now.hour() && EEminute1 == now.minute()) {
  digitalWrite(valve1, LOW);
  }
}
/*oid WeekDayState(int state){
  if (EEday0 || EEday1 || EEday2 || EEday3 || EEday4 || EEday5 || EEday6 >= 1){
    state == WeekDayOn;
  }
  else{
   state == WeekDayOff;
  }
}*/

now.dayOfTheWeek counts from 0-6
Thankfull for your ideas :slight_smile:

You should post your complete code and not just that error-laden snippet. It is otherwise very difficult to get an idea of what you are trying to do.
A first guess may be that you want to use an array to store the EEdayX variable values so that they are numerically indexable.

artazzs1:
Thankfull for your ideas :slight_smile:

I've just posted an updated, early version of a library that allows you, along with your RTC, to create very easy events that re-occur on a daily basis.

I've debugged it, it works well, but it is still a work in process which may have some changes down the road

If you want to try, you can find DailyTimer on GitHub.

Any comments are appreciated...

Would it make life easier to convert the time and date into an integer - perhaps the number of seconds since 1950?

Then any single time/date combination can be selected with single IF

...R

    daystate == 0;Oh dear ...

UKHeliBob:
    daystate == 0;Oh dear ...

This code It's just my toughts about it I know i doesnt work :slight_smile:
This is why I ask smart people for the ideas :stuck_out_tongue: