i'm fishing for pointers here... mainly because following forum threads and googling is sending round in circles....
i'm making a robotic thing that for most of the time does nothing, but maybe for 2 or 3 seconds every hour it will turn a motor, light an LED or make some tonelibrary warblings. i've been looking at millis() instead of delay() as there is also a button which needs to work if someone presses it.
just about every example i've seen and tried to intepret or adapt has been about using millis to make something happen for a while and then stop it happening. i'm trying to do the reverse - mostly nothing happens but after a long period it will happen.
i don't have any useful code snippets to post as i haven't really got anywhere but if someone could point me along the right path i'd appreciate it.
cheers
The loop function is called in an endless loop. On each pass, it determines what there is that needs to be done. Whether that is reading sensors, turning LEDs on, spinning motors, displaying data on an LCD, etc. does not matter.
Some of the stuff is time-dependent. Has the LED been on long enough? Is it time to turn the alarm on? Is it time to log data to the SD card?
Those kinds of things rely on either delay() or millis() to determine.
If there is nothing to do, or if everything has been done, loop ends, and is called again.
Long periods of time doing nothing is what the Arduino already does, quite well. Just like any other computer.
Perhaps it isn't clear why the way the Arduino normally works isn't sufficient.
For long time periods I would use a real-time clock IC like the DS1337.
Use the interrupt output of the DS1337 to trigger the event.
I have an interrupt example at
http://wiblocks.luciani.org/docs/app-notes/nb1a-rtc-alarms.html
(* jcl *)
www: http://www.wiblocks.com
twitter: http://twitter.com/wiblocks
blog: http://luciani.org
Or, if exact timing is not necessary, you could use the date/time library.
thanks for your responses;
pauls for a philosophical look at the arduino
jluciani for a clock i will surely look at for future work
sciguy for the synchronicity...
i was just looking at the datetime library and wondering if it was an 'easier' way of doing what i need, seeing as exact timing is not at all necessary. actually, i downloaded the time library - the datetime page says it is 'enhanced' and i couldn't resist.
looks like it could be just the ticket. tomorrow i'll find out...