Do you have a question on how to do something.
Ask in here.
tyson_mitchell_88
Posts: 80 Joined: Thu Nov 05, 2015 2:45 pm
Location: Australia
Post
by tyson_mitchell_88 » Sat Jan 23, 2016 2:27 am
Hi,
I need to flick a port off and on again. Thought something like this but I'm not sure if I'm remotely right.
Code: Select all
//White off
if (hour()==18 && minute()==30 && second()>=0 && hour()==18 && minute()==30 && second()<2)
{
ReefAngel.Relay.Off(Port8);
} else {
ReefAngel.Relay.On(Port8);
}
Or is it just
Code: Select all
//White off
if (hour()==18 && minute()==30 && second()==0)
{
ReefAngel.Relay.Off(Port8);
} else {
ReefAngel.Relay.On(Port8);
}
cosmith71
Posts: 1437 Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City
Post
by cosmith71 » Sat Jan 23, 2016 4:53 am
Either of those should work. I'd go with the first one just because it has a little more delay.
Be aware that except for those two seconds, that port will ALWAYS be on with that code. You would also need to place it after any other code that controls that port.
tyson_mitchell_88
Posts: 80 Joined: Thu Nov 05, 2015 2:45 pm
Location: Australia
Post
by tyson_mitchell_88 » Sat Jan 23, 2016 5:32 am
So if I go with this it should just turn off for those 2 sec. Otherwise will be on 500 > 2100.
Thanks Colin
Code: Select all
//White off
if (hour()==18 && minute()==30 && second()>=0 && hour()==18 && minute()==30 && second()<2)
{
ReefAngel.Relay.Off(Port8);
} else {
ReefAngel.StandardLights( Port8,5,00,21,00 );
}
cosmith71
Posts: 1437 Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City
Post
by cosmith71 » Sat Jan 23, 2016 5:41 am
There are a couple of ways.
You can do it the way you have posted.
You can do this, too.
Code: Select all
//White off
if (hour()==18 && minute()==30 && second()<2)
{
ReefAngel.Relay.Off(Port8);
} else {
ReefAngel.StandardLights( Port8,5,00,21,00 );
}
You could also have the StandardLights up higher in your loop() and leave out the else completely.
Code: Select all
loop()
ReefAngel.Standardlights( Port8,5,0,21,0);
.
.
.
.
.
.
.
if (hour()==18 && minute()==30 && second()<2)
{
ReefAngel.Relay.Off(Port8);
}
--Colin
tyson_mitchell_88
Posts: 80 Joined: Thu Nov 05, 2015 2:45 pm
Location: Australia
Post
by tyson_mitchell_88 » Sat Jan 23, 2016 5:52 am
Yep changing it to the second way. Should of thought of it from the start lol. Thanks mate