Here it is in a nutshell
I have been a week trying to get this code to run.\
I live in time of use for power with weekends and nights cheaper.
Trying to turn relay off dalily mon-fri.
Lines 121 to 125 is killing me
the if statement is saying if it is not a sunday or Saturday, checkn the time and if high power stay off.
How ever no matter how I code the OR statement italways returns a true and runs the printheatOff ()
why can I not get the OR statement to be a false for the weekend?
aug_3_ds1307_hot_water_timer.ino (6.05 KB)
From looking at this code, it is really not clear what you are trying to do.
It appears that you've been cutting and pasting code from random places without much regard as to what you've been cutting and pasting and how it is supposed to work together.
What are you trying to do, really? I don't just mean that particular part of your sketch, I mean your sketch as a whole. Apparently, you want your sketch to behave differently depending of the day of the week: how does it "know" what day of the week it is in the first place?
What is this supposed to say?
if((!(daysOfTheWeek[now.dayOfTheWeek()])==(0)) || (!(daysOfTheWeek[now.dayOfTheWeek()])==(6))) { // tell the time of day i moved the! to the end
-
Your have a ridiculous lot of ( and ).
2)
daysOfTheWeek is an array of character strings; why do you compare a character string with an integer?
This would make a little more sense (if I understand the code correctly)
if(now.dayOfTheWeek() != 0 || now.dayOfTheWeek() != 6)
{
Next there is something wrong with that; if it's not 0 (so 1..6) or it's not 6 (so 1..5) So fill in a number and the result of that if will always be true. I guess I'm not understanding what it's supposed to do.
if (dayOfTheWeek != 0 || dayOfTheWeek != 6)
"If it's not Saturday or it's not Sunday, do something". Of course, no matter what the day of the week, it will always be either not Saturday or not Sunday.
sterretje:
Next there is something wrong with that; if it's not 0 (so 1..6) or it's not 6 (so 1..5) So fill in a number and the result of that if will always be true. I guess I'm not understanding what it's supposed to do.
PaulMurrayCbr:
"If it's not Saturday or it's not Sunday, do something". Of course, no matter what the day of the week, it will always be either not Saturday or not Sunday.
spycatcher already pointed out in #2 that that should probably have been && not ||, ie if it's not Saturday AND it's also not Sunday, do something.
Yes, look closer to your "if" statements.
Using "if(dayOfWeek != 0 || dayOfWeek !=6)" will always be TRUE !
cpehonk:
Using "if(dayOfWeek != 0 || dayOfWeek !=6)" will always be TRUE !
OP's been told that line's wrong 4 times now; only spycatcher (who also happened to answer first) actually suggested a fix.
One does not necessarily have to provide a solution. Pointing out the error should make the OP think.