Delay question

I'm a beginner so please excuse my ignorance.

If I want to program an 8 hr. delay do I program 480000ms or is there an "hour, minute, second" command in the programming language? Also can someone recommend a method of energy conservation to minimize the electrical consumption during a lengthy delay? Thanks.

As far as I know, millis is the only game in town unless you add hardware such as a real time clock. Don't forget to declare any variables you use to store millis as unsigned long and any constants you use will need a UL suffix e.g. 60000UL. For power consumption help, search the forum for watchdog timer.

Edit: BTW - 480000ms is eight minutes.

Have a look at the TimeAlarms library.
Set an alarm to go off in 8 hours and run a function that you specify.
Job done.

Thanks wildbill. Oops, I meant 28800000ms - see what I mean? Dealing with ms for lengthy timing gets somewhat unwieldy.

UKHeliBob:
Have a look at the TimeAlarms library. Set an alarm to go off in 8 hours and run a function that you specify. Job done.

Where would you suggest I look for TimeAlarms library info?

UKHeliBob:
Have a look at the TimeAlarms library.
Set an alarm to go off in 8 hours and run a function that you specify.
Job done.

D'oh! of course!

Which Arduino board? There is no way to shutdown the USB chip on boards such as Uno and Mega AFAIK,
so putting the microcontroller into a sleep mode won't drastically reduce current consumption. Usually you'd
need an real-time-clock chip if going that route as running the microcontroller's 16MHz clock is a large part
of the current consumption.

Its worth searching these forums carefully there have been several lengthy threads on this sort of thing.

PlayStationFarm:
Where would you suggest I look for TimeAlarms library info?

Google? :slight_smile:

TimeAlarms is included in the Time library:

http://playground.arduino.cc/Code/time

Unfortunately the playground does not include documentation for it though. But see the example sketch--and the readme file in the library folder that you install.

And google. LMGTFY - Let Me Google That For You

Cheers,
John

I meant 28800000ms - see what I mean? Dealing with ms for lengthy timing gets somewhat unwieldy.

so, don't do it. Let the compiler take the strain8UL * 60UL * 60UL * 1000UL.
Of course, you could also name the constants.

PlayStationFarm:
Also can someone recommend a method of energy conservation to minimize the electrical consumption during a lengthy delay?

See this for tips on saving power: http://www.gammon.com.au/power