Quantcast
Channel: Arduino Forum - Latest topics
Viewing all articles
Browse latest Browse all 15454

Working hours logic

$
0
0

Hi,
I am up to make a project where certain things will be done but in a specific frame of time every day.
Firstly, it was ok to have only hours time frame:


if (hr >= startHour && hr < stopHour){
    do something
    }else{
      don't do something
      }

So if I have startHour = 8 and stopHour = 12, the thing will be done from 8 up to 12h. This is fine.

Now, I have to add minutes. Tried something like this:

if (hr >= startHour  && hr < stopHour){
    if(min >= startMin   && min < stopMin){
     do something
    }else{
      don't do something
      }
    }else{
      don't do something
      }

This works if the startMin is less than the stopMin. Say from 8:10 to 12:20, but it will not work if it is from 8:20 up to 12:10.

Anyone of you have messed with this logic? Any help would be nice.

22 posts - 9 participants

Read full topic


Viewing all articles
Browse latest Browse all 15454

Trending Articles