I made a small program to compare schedules, that is, if the time is between 10 AM and 5 PM PM the window is open and shows on the LCD "Open window".
If the time is outside 10 AM and after 5 PM the window is closed and shows on the LCD "Closed window"
The program I made does not work in the comparison part of the schedules, ie it does not show in the Lcd the messages of "window open or closed"
Can someone edit my code and explain why it does not work?
Thank you very much in advance
I thought I could do these two comparisons as I did in the code, now I have no idea how to do it, if I can help thanks
I did several searches on google and I did not find anything that could help me
Have a look at the difference between the logical AND (&&) that you used and a logical OR (||). That might help. And are you sure you mean > 17? If you use that 17:59 is in your time range (the hour is not greater than 17).
slipstick:
Have a look at the difference between the logical AND (&&) that you used and a logical OR (||). That might help. And are you sure you mean > 17? If you use that 17:59 is in your time range (the hour is not greater than 17).
Steve
Hi slipstick
Thank you for your support
I already did the tests with the logic (&&) and ( ||) it still does not work!
Unfortunately I do not know how to compare like you said 17:59 PM, as I did the code the comparison does not admit to doing 17; 59!
Anyway, I appreciate any help
Thanks for your support.
I have modified the code to only compare schedules, because that is what is not working, so it does not show open or closed window messages!
I've done several tests with all my little knowledge but I'm not successful
Once again I thank you for your help.
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!
Let's try again. The test you've written (with the &&) is testing if hour is less than or equal to 10 AND AT THE SAME TIME hour is greater than or equal to 13. It can't possibly be true.
What we all think you mean if hour <= 10 OR ELSE hour >=13.
You can make as many comparisons as you like (within reason) but you must do it the right way
I assume that this
if ((now.hour() <= 10 ) && (now.hour() > 13 ))
is intended to test whether the hour is less than or equal to 10 or that the hour is greater than 13.
Is that what you want to test for ?
If not, then what do you want it to test for ?
Hi UKHeliBob
I'll try to explain what I'm about to do.
Yes, what I really need is a program that, from 10:00 a.m. to 5:00 p.m., show me on the LCD "open window", and that from 5:00 p.m. to 10:00 p.m. Show me the morning on the Lcd "closed window"
The clock is working fine, it shows the date and time on the LCD without any problem, now these comparisons of the schedules is that it does not work.
slipstick:
Let's try again. The test you've written (with the &&) is testing if hour is less than or equal to 10 AND AT THE SAME TIME hour is greater than or equal to 13. It can't possibly be true.
What we all think you mean if hour <= 10 OR ELSE hour >=13.
OR is written as ||. AND is written &&.
Steve
Hi Steve.
Thank you for your help, but unfortunately I do not quite understand what you mean by;
What we all think you mean if hour <= 10 OR ELSE hour >=13.
It doesn't help that you keep changing the times you're talking about.
I think what you mean is what you originally said: If the current time is from 10am up to but not including 5pm (17:00) show "Window open" or if it is not between those times show "Window closed". Is that right?
If so then surely all you need is something as simple as:
if ((hour >9) && (hour <17){
do the show "Window Open" stuff
}
else{
do the show "Window Closed" stuff
}