Turn relay on/off at specific times

Do you have a question on how to do something.
Ask in here.
Post Reply
benjy1234
Posts: 19
Joined: Mon May 23, 2016 7:22 pm

Turn relay on/off at specific times

Post by benjy1234 »

Sorry about the noob question

I have a small powerhead id like to turn on for a few minutes at a time multiple times during the day. I use it to create some turbulent water in my sump when my doser comes on. I want it to come on at around 4:50am till 5:10am then at the same intervals at 6am 9pm and 10 pm. THis is what I tried but it just leaves the pump on:

if (hour()>=4,53 && hour()<5,07)
{
ReefAngel.Relay.On(Port7);
}
else
{
ReefAngel.Relay.Off(Port7);
}

if (hour()>=5,53 && hour()<6,07)
{
ReefAngel.Relay.On(Port7);
}
else
{
ReefAngel.Relay.Off(Port7);
}

if (hour()>=20,53 && hour()<21,07)
{
ReefAngel.Relay.On(Port7);
}
else
{
ReefAngel.Relay.Off(Port7);
}

if (hour()>=21,53 && hour()<22,07)
{
ReefAngel.Relay.On(Port7);
}
else
{
ReefAngel.Relay.Off(Port7);
}

Thanks for any help! You guys are awesome!
Image
User avatar
cosmith71
Posts: 1437
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: Turn relay on/off at specific times

Post by cosmith71 »

Your if statements need to look like this:

Code: Select all

if ((hour() >= 4 && minute() >= 53) && (hour() <5 && minute() < 7))
Just change the hour and minutes appropriately for each section. I think the rest is fine.

--Colin
benjy1234
Posts: 19
Joined: Mon May 23, 2016 7:22 pm

Re: Turn relay on/off at specific times

Post by benjy1234 »

Oh perfect! Thanks Colin!
Image
User avatar
cosmith71
Posts: 1437
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: Turn relay on/off at specific times

Post by cosmith71 »

You're welcome!
Post Reply