//FEEDING MODE
// Begin Feeding Mode
if (((hour() == 7)) && (minute() == 30) || (hour() == 18) && (minute() == 00)) {
ReefAngel.FeedingModeStart(); // FEEDING MODE @ 7:30 AM or 6:00 PM
NoteTime = millis();
unsigned long DeltaTS = millis() - NoteTime;
if ( DeltaTS >= 130000 ) ReefAngel.Relay.Off(Feeder); // turn off 2 minutes 10 secs
else
if ( DeltaTS >= 120000 ) ReefAngel.Relay.On(Feeder); // turn on after 2 minutes
else
if ( DeltaTS >= 70000 ) ReefAngel.Relay.Off(Feeder); // turn off 1 min 10 secs
else
if ( DeltaTS >= 60000 ) ReefAngel.Relay.On(Feeder); // turn on after 1 minute
}
You are definitely on the right track. This will almost work, but you are only giving everything 1 minute to complete, even though you have 2 minute and 10 seconds worth of events programmed. Here is how I would change it:
// Static bool to track if we are currently feeding or not
static boolean feedingActive = false;
//FEEDING MODE
// Begin Feeding Mode
if (((hour() == 7)) && (minute() == 30) || (hour() == 18) && (minute() == 00)) {
ReefAngel.FeedingModeStart(); // FEEDING MODE @ 7:30 AM or 6:00 PM
NoteTime = millis(); // Grab millis value of when feeding mode started
feedingActive = true; // We are entering feeding mode, so set to true
}
if (feedingActive) {
unsigned long DeltaTS = millis() - NoteTime;
if ( DeltaTS >= 130000 ) {
ReefAngel.Relay.Off(Feeder); // turn off 2 minutes 10 secs
feedingActive = false; // Feeding mode is now over, set to false
} else
if ( DeltaTS >= 120000 ) ReefAngel.Relay.On(Feeder); // turn on after 2 minutes
else
if ( DeltaTS >= 70000 ) ReefAngel.Relay.Off(Feeder); // turn off 1 min 10 secs
else
if ( DeltaTS >= 60000 ) ReefAngel.Relay.On(Feeder); // turn on after 1 minute
}
The code above would even allow you to use feedingActive elsewhere in your code, if you wanted to do things based on whether or not you are in feeding mode.
//FEEDING MODE
// Begin Feeding Mode
if (((hour() == 7)) && (minute() == 30) || (hour() == 18) && (minute() == 00)) {
ReefAngel.FeedingModeStart(); // FEEDING MODE @ 7:30 AM or 6:00 PM
NoteTime = millis();
unsigned long DeltaTS = millis() - NoteTime;
if ( DeltaTS >= 130000 ) ReefAngel.Relay.Off(Feeder); // turn off 2 minutes 10 secs
else
if ( DeltaTS >= 120000 ) ReefAngel.Relay.On(Feeder); // turn on after 2 minutes
else
if ( DeltaTS >= 70000 ) ReefAngel.Relay.Off(Feeder); // turn off 1 min 10 secs
else
if ( DeltaTS >= 60000 ) ReefAngel.Relay.On(Feeder); // turn on after 1 minute
}
You are definitely on the right track. This will almost work, but you are only giving everything 1 minute to complete, even though you have 2 minute and 10 seconds worth of events programmed. Here is how I would change it:
// Static bool to track if we are currently feeding or not
static boolean feedingActive = false;
//FEEDING MODE
// Begin Feeding Mode
if (((hour() == 7)) && (minute() == 30) || (hour() == 18) && (minute() == 00)) {
ReefAngel.FeedingModeStart(); // FEEDING MODE @ 7:30 AM or 6:00 PM
NoteTime = millis(); // Grab millis value of when feeding mode started
feedingActive = true; // We are entering feeding mode, so set to true
}
if (feedingActive) {
unsigned long DeltaTS = millis() - NoteTime;
if ( DeltaTS >= 130000 ) {
ReefAngel.Relay.Off(Feeder); // turn off 2 minutes 10 secs
feedingActive = false; // Feeding mode is now over, set to false
} else
if ( DeltaTS >= 120000 ) ReefAngel.Relay.On(Feeder); // turn on after 2 minutes
else
if ( DeltaTS >= 70000 ) ReefAngel.Relay.Off(Feeder); // turn off 1 min 10 secs
else
if ( DeltaTS >= 60000 ) ReefAngel.Relay.On(Feeder); // turn on after 1 minute
}
The code above would even allow you to use feedingActive elsewhere in your code, if you wanted to do things based on whether or not you are in feeding mode.
So I was looking at this code and doing some testing and learned that it doesn't compile because the second part declares "unsigned long DeltaTS = millis() - NoteTime;" based on the if/then condition above it. It says that NoteTime was not declared.
You said you had NoteTime declared globally earlier. If not, just put unsigned long NoteTime either in the top of the function or in a global declaration.