Time specific programs

Hi! I have a problem, I need to run a program only between certain hours.

Is it possible only to run the program from 1pm-3pm every day? I have searched for a long time and can find no help on the internet, maybe one of you might know how this is possible. It would be really good if you could help

Thanks

Without a real time clock, the Arduino has no idea what time it is. With a real time clock, what you want to do is trivial. Do you have one?

No I don't, this is at the moment still an Idea- I am finding out about things before I build, but if necessary I will buy a clock as well as the other things, how would this work?

how would this work?

Depends on the particular RTC and library. With a DS1307, there is a method to get the time, and then the time object has methods to get hours, minutes, seconds, etc.

ifInow.hour() >= 13 && now.hour() <= 15)
{
   // Do the 1:00 to 3:00pm stuff...
}

sausages:
Is it possible only to run the program from 1pm-3pm every day?

Either give your Arduino a real-time clock and write a sketch that only does stuff during the hours you want, or get an ordinary domestic timer and set that to turn on during the hours you want, use that to power a wall wart that powers the Arduino.

Thank you so much!

PeterH:

sausages:
Is it possible only to run the program from 1pm-3pm every day?

or get an ordinary domestic timer and set that to turn on during the hours you want, use that to power a wall wart that powers the Arduino.

A fine example of thinking outside the box... :slight_smile: