Timekeeping without RTC+ Interrupt?

Hi!

My first packege with Arudino stuff is on it´s way for my home automation projects are taking form in my head.

My first project will be a dry food feeder for the dog.
Thought a servo that can rotate continuously will turn the feeder for X ms for the right amount of dry food.
Then the Arduino will wait for 24 hours before it´s time again.
This way if I want to food the dog 18:00, I just power on the Arduino at 18:00 and it will dispense dryfood every 24 hour.

How can I program the Arduino to wait 24 hours without a RTC chip?
I checked this but I can´t see how the int can keep that high amount of miliseconds

Also, there will be a button, if pressed it will dispense some additional food.
(That would be the interrupt).

Can I start a counter when the Arduino is powered on and use a IF when the counter have waited for 24 hours?

For example:

void setup()
{
TempServo.attach(13);
Ini 24Timer start
}

void loop()
{
IF 24timer = 24hours;
TempServo.write(110); //Dispense food
delay(1800);

IF Button = 1
TempServo.write(110); //Dispense food
delay(1800);
}

You certainly can, but it is not very accurate. If your dog does not mind changing its feeding time a few minutes each day...

But you don't need interrupts. For something like this simply *polling the RTC every second or so would be sufficient.

*polling means that you regularly ask the RTC what time it is.

Why is the Arduino timer not accurate? (Minutes change every day).

Also I do not have an RTC chip.
Thant´s why I ask about timer (Or something similar)

Maybe I can use the "millis()" ?
Or will it not be accurate either?

Accuracy is relative. The dog won't mind a minute or two off, so millis is fine to use.

Will the timer add one or two minutes every time? Or the Arduino execute the code 18:00 plusminus 2 minutes?

istvanuino:
Will the timer add one or two minutes every time? Or the Arduino execute the code 18:00 plusminus 2 minutes?

Maybe a minute more. Maybe less. It will drift a little. The dog won't notice.

istvanuino:
I checked this but I can´t see how the int can keep that high amount of miliseconds

https://www.arduino.cc/en/Reference/Delay
Apparently, the delay() function takes an unsigned long as input. Go ahead, try delay(86400000UL) and see what happens.

One other problem that you will more than likely encounter is a power failure / reset of the arduino. You're timing will be lost. You also might need to set the initial time or start the Arduino at 'exactly' 6 o'clock.

A RTC is a million times ( :wink: ) easier.