Arduino to use time

Hello, I want to use Arduino to turn on sth on specific time.
for example:
I want to turn on my relay at 7:40AM, keep it on for 5 seconds then turn off.
Should I buy extra shield? or is there way to configure it with program?

ibilgee:
or is there way to configure it with program?

How does your Arduino board detect time 7:40AM?

You need something like a RTC module ( realtime clock) connected to your Arduino, for setting and getting accurate absolute time. Preferably a DS3231 high precision RTC module.

It is possible to program the Arduino to act as a clock. I have done it. But there are two problems with doing this:

  1. The Arduino does not keep very good time. You can probably trust it to be accurate to within 1 or 2 minutes per day. Keep in mind that if you let it run for many days or weeks, it will probably drift very far from the correct time.
  2. Every time you restart or reset the Arduino, it will "forget" the time. If the Arduino loses power, it will lose track of the time and you will need to set the time again. I had this problem with my Arduino clock. I ended up putting buttons on it so that I could set the time easily.

What jurs means by an "RTC module" is a device that does for your Arduino what a wristwatch does for you or me. You could try to measure time by saying "one Mississippi, two Mississippi, ...". Or you could just use your wristwatch to measure time, and not have to worry about whether you are counting at the right speed or what happens if you lose count.

Once I put an RTC module on my Arduino clock, it kept essentially perfect time. I could also remove the Arduino from its power supply and not have to worry, because as soon as it got power again, it was able to read the correct time from the RTC module. (I had installed a backup battery on this RTC module. The battery did not power the Arduino, it only powered the module.)