Outlet programming base on day of the week

Do you have a question on how to do something.
Ask in here.
Post Reply
ganjero
Posts: 145
Joined: Fri Jul 05, 2013 5:29 am

Outlet programming base on day of the week

Post 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
Image
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Outlet programming base on day of the week

Post by rimai »

Try something like this:

Code: Select all

ReefAngel.Relay.Set(Port3, weekday()==dowSaturday || weekday()==dowSunday));
Roberto.
ganjero
Posts: 145
Joined: Fri Jul 05, 2013 5:29 am

Re: Outlet programming base on day of the week

Post by ganjero »

Thanks Roberto,

how would I do the same but to turn off another outlet while that one is on?
Image
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: Outlet programming base on day of the week

Post 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.
ganjero
Posts: 145
Joined: Fri Jul 05, 2013 5:29 am

Re: Outlet programming base on day of the week

Post 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)
Image
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: Outlet programming base on day of the week

Post 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 ) );
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: Outlet programming base on day of the week

Post 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));
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Outlet programming base on day of the week

Post 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 ) );
Roberto.
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Outlet programming base on day of the week

Post 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.
Roberto.
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: Outlet programming base on day of the week

Post 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 ) );
ganjero
Posts: 145
Joined: Fri Jul 05, 2013 5:29 am

Re: Outlet programming base on day of the week

Post by ganjero »

Thanks everyone
Image
Post Reply