Turn relay on/off at specific times

Do you have a question on how to do something.
Ask in here.

Posts: 14
Joined: Mon May 23, 2016 7:22 pm
PostPosted: Fri Mar 03, 2017 11:26 pm
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
Posts: 1426
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City
PostPosted: Sat Mar 04, 2017 4:53 am
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

Posts: 14
Joined: Mon May 23, 2016 7:22 pm
PostPosted: Sat Mar 04, 2017 3:54 pm
Oh perfect! Thanks Colin!
Image
User avatar
Posts: 1426
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City
PostPosted: Sat Mar 04, 2017 4:29 pm
You're welcome!

Return to How do I code ...

Who is online

Users browsing this forum: No registered users and 1 guest