Page 1 of 1

Outlet programming base on day of the week

Posted: Sun Mar 16, 2014 12:49 pm
by ganjero
How do I program port 3 of my my relay extension to turn on Saturdays at 12:00am and off Monday at 12:00am?

Thanks

Re: Outlet programming base on day of the week

Posted: Sun Mar 16, 2014 5:32 pm
by rimai
Try something like this:

Code: Select all

ReefAngel.Relay.Set(Port3, weekday()==dowSaturday || weekday()==dowSunday));

Re: Outlet programming base on day of the week

Posted: Mon Mar 17, 2014 6:44 am
by ganjero
Thanks Roberto,

how would I do the same but to turn off another outlet while that one is on?

Re: Outlet programming base on day of the week

Posted: Mon Mar 17, 2014 7:55 am
by Sacohen
There is a code that gets set up in the wizard if you have for example you moonlights (port8) come on when your Actinic lights (port 3) go out

Code: Select all

ReefAngel.Relay.Set( 8, !ReefAngel.Relay.Status( 3 ) );
That's if port 8 is the port you want to have on when port 3 is off.
I think this will work with Roberto's code above.

Re: Outlet programming base on day of the week

Posted: Mon Mar 17, 2014 8:12 am
by ganjero
Thanks, but I'm looking for the opposite. A port to go off when one goes on, if it's not posssible then the code to turn off a port for specific days of the week (in my case Sat & Sun)

Re: Outlet programming base on day of the week

Posted: Mon Mar 17, 2014 8:16 am
by Sacohen
I haven't tried it, but I would think that if you reverse the code I pasted above would work.

Code: Select all

ReefAngel.Relay.Set( 3, !ReefAngel.Relay.Status( 8 ) );

Re: Outlet programming base on day of the week

Posted: Mon Mar 17, 2014 8:24 am
by lnevo
There are a few ways to skin the cat, but here's the question.. What do you want the port to do when it's not Saturday / Sunday?

Either way the code that Steve pasted will set the port to the opposite of the one you want.

If this is the code to turn on a port during the weekend

ReefAngel.Relay.Set(Port3, (weekday()==dowSaturday || weekday()==dowSunday));

then this will turn the port OFF during that time. (Note the addition of the exclamation mark to reverse the logic)

ReefAngel.Relay.Set(Port3, !(weekday()==dowSaturday || weekday()==dowSunday));

Re: Outlet programming base on day of the week

Posted: Mon Mar 17, 2014 9:12 am
by rimai
Sacohen wrote:There is a code that gets set up in the wizard if you have for example you moonlights (port8) come on when your Actinic lights (port 3) go out

Code: Select all

ReefAngel.Relay.Set( 8, !ReefAngel.Relay.Status( 3 ) );
That's if port 8 is the port you want to have on when port 3 is off.
I think this will work with Roberto's code above.
Hey Steve,
Make sure to use Port in front of the number or you won't get what you want.
Like this:

Code: Select all

ReefAngel.Relay.Set( Port8, !ReefAngel.Relay.Status( Port3 ) );

Re: Outlet programming base on day of the week

Posted: Mon Mar 17, 2014 9:15 am
by rimai
ganjero wrote:Thanks, but I'm looking for the opposite. A port to go off when one goes on, if it's not posssible then the code to turn off a port for specific days of the week (in my case Sat & Sun)
The ! sign means opposite.
http://arduino.cc/en/Reference/Boolean
So, in his example, Port8 would be set as the opposite of Port3. You can go through the wizard and choose opposite and you will see that it will generate the same code.

Re: Outlet programming base on day of the week

Posted: Mon Mar 17, 2014 9:20 am
by Sacohen
rimai wrote: Hey Steve,
Make sure to use Port in front of the number or you won't get what you want.
Like this:

Code: Select all

ReefAngel.Relay.Set( Port8, !ReefAngel.Relay.Status( Port3 ) );
Sorry, I'm at work trying to remember how things are programmed.
I have my ports defined so for me it was

Code: Select all

ReefAngel.Relay.Set( Moon_Lights, !ReefAngel.Relay.Status( Actinic_Lights ) );

Re: Outlet programming base on day of the week

Posted: Tue Mar 18, 2014 7:45 am
by ganjero
Thanks everyone