Multiple Light On Times

Do you have a question on how to do something.
Ask in here.
Post Reply
tmoore103
Posts: 12
Joined: Wed Nov 11, 2015 3:30 pm

Multiple Light On Times

Post by tmoore103 »

Hello fellow reefers,

I'm a newbie to both coding and the ReefAngel system so I'm hoping you pros can help me out. :D I got my system a few weeks ago for my nano reef and I absolutely love it! This will probably be pretty easy for you guys.

I'm trying to turn a port on at multiple scheduled times ( from 10 am to 11am and again from 11 pm to 7 am ) but I can't seem to figure it out. I've searched all over the forum but I can't seem to find what I'm looking for. So far I've tried these lines but couldn't get them to work.


First:

Code: Select all

ReefAngel.StandardLights( Port3,10,0,11,0 );
if (bitRead(ReefAngel.Relay.RelayData,Port3)==0)  ReefAngel.StandardLights( Port3,22,0,7,0 ); 
Then I thought maybe I was just complicating things so I tried this:

Code: Select all

ReefAngel.StandardLights( Port3,10,0,11,0 );
   ReefAngel.StandardLights( Port3,22,0,7,0 ); 
Then this:

Code: Select all

if (hour()>=10 && hour()<11)
 {
  ReefAngel.Relay.On ( Port3 );
 }
  else
 {
   ReefAngel.StandardLights( Port3,22,0,7,0 );
 }


I was getting an upload error when I tried the last so I tried adjusting the code a little. It eventually let me upload the last one but it doesn't look like it's working. Any help would be greatly appreciated.

Thanks!
-Tori
User avatar
cosmith71
Posts: 1437
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: Multiple Light On Times

Post by cosmith71 »

Try this:

Code: Select all

if ((hour()>=10 && hour()<11) || (hour()>=23 || hour()<7))
  {
    ReefAngel.Relay.On(Port3);
  }
  else
  {
    ReefAngel.Relay.Off(Port3);
  }
Or, more succinct and not as easy to understand (does the same thing)

Code: Select all

if (hour()==10 || hour()==23 || hour()<7)
  {
    ReefAngel.Relay.On(Port3);
  }
  else
  {
    ReefAngel.Relay.Off(Port3);
  }
Lots of ways to do it. :mrgreen:

--Colin
tmoore103
Posts: 12
Joined: Wed Nov 11, 2015 3:30 pm

Re: Multiple Light On Times

Post by tmoore103 »

Thanks Colin! Really appreciate the help man. Thanks for showing me more than one way to do it.
User avatar
cosmith71
Posts: 1437
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: Multiple Light On Times

Post by cosmith71 »

No problem. :)
bkc6868
Posts: 95
Joined: Wed Sep 02, 2015 4:39 pm

Re: Multiple Light On Times

Post by bkc6868 »

If the port is already programmed for a certain time to come on by the wizard and we use this code, does the wizard code have to be deleted for that port? I have that port set to come on from 2 till 10 , but want to use this for multiples times instead. I used the code and it come on at the time I set but didn't go off
Image
User avatar
cosmith71
Posts: 1437
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: Multiple Light On Times

Post by cosmith71 »

Whatever comes last in the code takes priority. Post your code and what you want to happen.

--Colin
bkc6868
Posts: 95
Joined: Wed Sep 02, 2015 4:39 pm

Re: Multiple Light On Times

Post by bkc6868 »

I used this code but changed the times in it to 10 a.m. on and off 2 p.m. I the wizard the port is supposed to run till 2pm till 10pm. After loading this cusom code with my time changes it cam on at 10a.m. but didnt shut off at 2p.m like the custom code was supposed to do them back on at 6pm till 10 pm
Image
bkc6868
Posts: 95
Joined: Wed Sep 02, 2015 4:39 pm

Re: Multiple Light On Times

Post by bkc6868 »

double post.. sorry
Image
User avatar
cosmith71
Posts: 1437
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: Multiple Light On Times

Post by cosmith71 »

The wizard code and the new code will conflict. We need to see the whole code you are using.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Multiple Light On Times

Post by lnevo »

Most likely we will want to take the wizard code and have the lights come on from 10am till 10pm then add a statement to turn them off between 2pm and 6pm
bkc6868
Posts: 95
Joined: Wed Sep 02, 2015 4:39 pm

Re: Multiple Light On Times

Post by bkc6868 »

Here is my wizard code. I took the custom code from above out

Code: Select all

[/co#include <ReefAngel_Features.h>
#include <Globals.h>
#include <RA_Wifi.h>
#include <Wire.h>
#include <OneWire.h>
#include <Time.h>
#include <DS1307RTC.h>
#include <InternalEEPROM.h>
#include <RA_NokiaLCD.h>
#include <RA_ATO.h>
#include <RA_Joystick.h>
#include <LED.h>
#include <RA_TempSensor.h>
#include <Relay.h>
#include <RA_PWM.h>
#include <Timer.h>
#include <Memory.h>
#include <InternalEEPROM.h>
#include <RA_Colors.h>
#include <RA_CustomColors.h>
#include <Salinity.h>
#include <RF.h>
#include <IO.h>
#include <ORP.h>
#include <AI.h>
#include <PH.h>
#include <WaterLevel.h>
#include <Humidity.h>
#include <DCPump.h>
#include <PAR.h>
#include <ReefAngel.h>

////// Place global variable code below here


////// Place global variable code above here


void setup()
{
    // This must be the first line
    ReefAngel.Init();  //Initialize controller
    ReefAngel.Use2014Screen();  // Let's use 2014 Screen 
    // Ports toggled in Feeding Mode
    ReefAngel.FeedingModePorts = Port2Bit | Port4Bit | Port5Bit | Port7Bit | Port8Bit;
    // Ports toggled in Water Change Mode
    ReefAngel.WaterChangePorts = Port2Bit | Port4Bit | Port5Bit | Port7Bit | Port8Bit;
    // Ports toggled when Lights On / Off menu entry selected
    ReefAngel.LightsOnPorts = 0;
    // Ports turned off when Overheat temperature exceeded
    ReefAngel.OverheatShutoffPorts = Port3Bit | Port6Bit | Port7Bit;
    // Use T1 probe as temperature and overheat functions
    ReefAngel.TempProbe = T1_PROBE;
    ReefAngel.OverheatProbe = T1_PROBE;
    // Set the Overheat temperature setting
    InternalMemory.OverheatTemp_write( 810 );


    // Ports that are always on
    ReefAngel.Relay.On( Port2 );
    ReefAngel.Relay.On( Port4 );

    ////// Place additional initialization code below here
    

    ////// Place additional initialization code above here
}

void loop()
{
    ReefAngel.StandardFan( Port1,785,790 );
    ReefAngel.StandardLights( Port3,14,0,22,0 );
    ReefAngel.StandardLights( Port5,6,0,18,0 );
    ReefAngel.StandardLights( Port6,14,0,22,0 );
    ReefAngel.StandardHeater( Port7,780,785 );
    ReefAngel.SingleATO( false,Port8,180,0 );
    ////// Place your custom code below here
    
    
    ////// Place your custom code above here

    // This should always be the last line
    ReefAngel.Portal( "bkc6868" );
    ReefAngel.DDNS( "www.reefangel.com" ); // Your DDNS is bkc6868-www.reefangel.com.myreefangel.com
    ReefAngel.ShowInterface();
}

de]
Image
User avatar
cosmith71
Posts: 1437
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: Multiple Light On Times

Post by cosmith71 »

Specifically, which ports do you want to run at what times? I'm still not sure what you're trying to do.

--Colin
bkc6868
Posts: 95
Joined: Wed Sep 02, 2015 4:39 pm

Re: Multiple Light On Times

Post by bkc6868 »

Port 3 from 10am to 2 pm and again at 6 pm to 10 pm
Image
User avatar
cosmith71
Posts: 1437
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: Multiple Light On Times

Post by cosmith71 »

Change this line:

Code: Select all

ReefAngel.StandardLights( Port3,14,0,22,0 );
to this:

Code: Select all

ReefAngel.StandardLights( Port3,10,0,22,0 );
if (hour() >=14 && hour() <18) ReefAngel.Relay.Off(Port3);
bkc6868
Posts: 95
Joined: Wed Sep 02, 2015 4:39 pm

Re: Multiple Light On Times

Post by bkc6868 »

Thank you!
Image
Post Reply