Sleep Function (not delay)

I was wondering if anyone knew how one might program a sleep function that actually sleeps the arduino microprocessor and wakes up after a preset number of milliseconds or clock cycles. I would imagine this could be done with the watchdog timer. Basically, I don't want to use the delay function, as that is just a while loop. I really want to sleep the chip (for power saving reasons) and wait for a timed interrupt.

Any advice or code would be greatly appreciated, Chris


I had the same request...

Matthias really helped me out. The code he posted (and I adapted for my project) is here

It's not technically a "sleep" state, but it's relatively low power, and then a timer interrupt is used to run a function at regular intervals.

Have a look at the code, I'd be happy to try to answer any questions using my limited experience.

Note the code is for ATMega8, some of the register names would need to be changed to get it working with a Mega168

Not sure about waking up at a certain time but there is code to sleep the processor on the playground and wake it up with a interrupt.