feed timer

Do you have a question on how to do something.
Ask in here.
Post Reply
Thavngr98
Posts: 83
Joined: Sun Jul 29, 2012 6:47 pm
Location: Long Island, NY

feed timer

Post 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
-Dave

Image
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: feed timer

Post 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();
}
Roberto.
Thavngr98
Posts: 83
Joined: Sun Jul 29, 2012 6:47 pm
Location: Long Island, NY

Re: feed timer

Post by Thavngr98 »

sorry I should of told you feed mode should toggle relay 1 and 5
-Dave

Image
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: feed timer

Post 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);
Roberto.
Thavngr98
Posts: 83
Joined: Sun Jul 29, 2012 6:47 pm
Location: Long Island, NY

Re: feed timer

Post by Thavngr98 »

I take it I add this to the custom code section of the INO file?
-Dave

Image
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: feed timer

Post 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
Roberto.
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: feed timer

Post 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.
Roberto.
kimacom
Posts: 33
Joined: Fri Jul 27, 2012 9:52 am

Re: feed timer

Post by kimacom »

Great post.
i was looking for it.

thank you guys.
Tim
Post Reply