Resetting the clock in Arduino

Good Morning. I have made a project of a fellow Internet user, which consists of a pet feeder, with two hours scheduled to dispense the food. The problem is that when the food is given, according to the first programming that is at 8:00 am, the clock is reset and set to 0: 00h. I do not know which is the flaw in the program, since I am a novice in this matter. I would like someone to tell me the error to correct it and get the time is constantly maintained. The correct operation should be as follows: there must be a clock that sets the time at all times, for when the time of the 2 shots is programmed, I acted according to this programming and also that the shot is always the same amount, as long as it is not Indicate otherwise through the menu.

Programa_comedero.ino (13.4 KB)

"Neko" is the name of your cat ?

It seems the time is set using buttons on the LCD module, is that correct?

The code is quite complex, I believe the time is changed in the routine called updateTime, called in the loop. I haven't seen any flaw in the sketch indicating any time reset.

You should add some Serial.prints in this routine to monitor the time changes and see if it resets to 0 after the first alarm.

Maybe it is the whole Arduino that is getting reset?

The Arduino doesn't have a clock, so talking of resetting the clock is pointless.

What your program does is keep track of the ticks of the oscillator, so that it pretends to have a clock.

The number of ticks bears no relationship to the actual time of day. That is why you have so much code to set the time on your "clock". An RTC would have been a much better option.

I can't see anything in the code that changes the time on the "clock" when a feeding cycle is complete.

You'll need to add Serial.print() statements in strategic places. For instance, does setup() get called more than once? It should not, so it you see that setup() is called more than once, you need to determine why the Arduino is being reset. Could be a voltage spike. Could be an array out of bounds write the trashes memory you don't own.

Thank you very much for the answers. The problem is that everything works well until it dispenses the first shot, once served is set the clock to 0:00 H. I'm a rookie in programming so I don't know what part of the program influences the clock

I'm guessing a problem with the dispenser mechanism spiking the power supply.

Please post your schematic

I'm a rookie in programming

You've got over 13k of code :o

AWOL:
I’m guessing a problem with the dispenser mechanism spiking the power supply.

Please post your schematic
You’ve got over 13k of code :o

Adjunto el esquema, creo que tiene razón, en el diseño original pide alimentación de 4,2 A y yo le estoy suministrando solo 1,2 A.