Page 1 of 1
feed timer
Posted: Wed Aug 08, 2012 6:38 pm
by Thavngr98
Can someone write me the code to daily
Turn feed mode on at 7:55
Turn feed mode off (turn everything back on) at 8:15
Turn feed mode on at 18:55
Turn feed mode off (turn everything back on) at 19:15
Re: feed timer
Posted: Wed Aug 08, 2012 9:05 pm
by rimai
Try this:
Code: Select all
#include <Salinity.h>
#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 <RF.h>
#include <IO.h>
#include <ORP.h>
#include <AI.h>
#include <PH.h>
#include <WaterLevel.h>
#include <ReefAngel.h>
void setup()
{
ReefAngel.Init();
ReefAngel.Timer[FEEDING_TIMER].SetInterval(1200);
ReefAngel.FeedingModePorts = Port8Bit;
ReefAngel.Relay.On(Port8);
}
void loop()
{
if(hour()==7 && minute()==55 && second()==0) ReefAngel.FeedingModeStart();
if(hour()==18 && minute()==55 && second()==0) ReefAngel.FeedingModeStart();
ReefAngel.ShowInterface();
}
Re: feed timer
Posted: Thu Aug 09, 2012 5:04 am
by Thavngr98
sorry I should of told you feed mode should toggle relay 1 and 5
Re: feed timer
Posted: Thu Aug 09, 2012 7:57 am
by rimai
That's fine.
Just change this:
Code: Select all
ReefAngel.FeedingModePorts = Port8Bit;
ReefAngel.Relay.On(Port8);
To this:
Code: Select all
ReefAngel.FeedingModePorts = Port1Bit | Port5Bit;
ReefAngel.Relay.On(Port1);
ReefAngel.Relay.On(Port5);
Re: feed timer
Posted: Thu Aug 09, 2012 8:19 am
by Thavngr98
I take it I add this to the custom code section of the INO file?
Re: feed timer
Posted: Thu Aug 09, 2012 8:27 am
by rimai
Yes, but make sure you merge the two sections of the 3 custom sections.
The 1st section is for global variables declaration, which we did not use in this code.
Code: Select all
////// Place global variable code below here
////// Place global variable code above here
The 2nd section is inside the setup() function and deals with initializing stuff and only happens once, which would be this:
Code: Select all
////// Place additional initialization code below here
ReefAngel.Timer[FEEDING_TIMER].SetInterval(1200);
ReefAngel.FeedingModePorts = Port1Bit | Port5Bit;
ReefAngel.Relay.On(Port1);
ReefAngel.Relay.On(Port5);
////// Place additional initialization code above here
And the 3rd is the section inside loop(), which is stuff the controller will do stuff and monitor, which would be this:
Code: Select all
////// Place your custom code below here
if(hour()==7 && minute()==55 && second()==0) ReefAngel.FeedingModeStart();
if(hour()==18 && minute()==55 && second()==0) ReefAngel.FeedingModeStart();
////// Place your custom code above here
Re: feed timer
Posted: Thu Aug 09, 2012 8:30 am
by rimai
BTW, there is no harm if you placed everything in the 3rd section too...
You could have done that. The controller will do just the same thing in this case. Just for the point of view of code organization is we prefer to place the stuff where they should be and not simply bunch everything up in the same spot.
Re: feed timer
Posted: Fri Aug 10, 2012 11:43 am
by kimacom
Great post.
i was looking for it.
thank you guys.
Tim