I'm building an automatic chicken feeder and I've got all my sensors, and a screen working fine.
The one thing that's giving me grief is the servo side of things. I'm using the Time/TimeAlarm libraries to set alarms which will move the servo. In my code I'm setting it to activate once per day. So, for example:
Alarm.alarmRepeat(17,30,0,EveningAlarm);
By rights it should only activate at 17:30 each day. And it does. But after that it activates about every 12 minutes.
I don't know the Alarm library or why it keeps repeating but you can easily stop it by setting a variable to record that the alarm action has happened. For example
void EveningAlarm(){
if (alarmDone == false) {
Serial.println("Alarm!");
digitalWrite(greenLED, HIGH); // GREEN LED ON
dispense(opened,closed);
digitalWrite(greenLED, LOW); // GREEN LED OFF
alarmDone = true;
}
}
You would obviously need to set alamDone back to false at some other time of the day.
Yes, I do see the 'alarm!' print and the FEEDING on the LCD screen.
OK, its evident that the alarm itself is being retriggered.
I would suggest modifying the EveningAlarm() function to include a print out of the time with a call to digitalClockDisplay. It's possible that there is something wrong with the rtc sync, or a memory problem as has been suggested, and the program is loosing the correct time and is resetting to before the alarm is triggered and will retrigger the alarm when the trigger time comes around again.
void EveningAlarm(){
Serial.println("Alarm!");
digitalClockDisplay();
digitalWrite(greenLED, HIGH); // GREEN LED ON
dispense(opened,closed);
digitalWrite(greenLED, LOW); // GREEN LED OFF
}
cattledog:
OK, its evident that the alarm itself is being retriggered.
I would suggest modifying the EveningAlarm() function to include a print out of the time with a call to digitalClockDisplay. It's possible that there is something wrong with the rtc sync, or a memory problem as has been suggested, and the program is loosing the correct time and is resetting to before the alarm is triggered and will retrigger the alarm when the trigger time comes around again.
void EveningAlarm(){
Serial.println("Alarm!");
digitalClockDisplay();
digitalWrite(greenLED, HIGH); // GREEN LED ON
dispense(opened,closed);
digitalWrite(greenLED, LOW); // GREEN LED OFF
}
I have the code printing the time to the serial every few seconds, so I can see exactly the time when it triggers.
Tried it again this evening. Triggered on time at 18:03 then triggered (when it shouldn't have) at 18:07