Background timer with ATTINY85 and virtualwire


I want to run some code on a ATTINY85 which is also using virtualwire. I want a timer to run in the background so that after a certain period (say five minute), the sleepmode function is called. This is so that if I forget to turn it off, it effectively turns itself off to save batteries and needs to be reset (or turned off and on again) to work again.

An obvious way to do this is with millis() but as others have found, millis() doesn't work with the ATTINY85 if virtualwire is also running.

Is there a way to use the watchdog timer function to achieve what I want? Or another way?


Hey I found this which may be useful:

I found it on this page: Arduino Playground - Time

Thanks but I don't think that will work because the DateTime.cpp also uses millis

Make your own counter like

Void loop() {
   If (counter/50000 > 5) serial.print("bingo");


It's a background timer I want - I.e. one that allows the rest of the code to operate and then effectively triggers an interrupt when the time is up. Your code will just produce a delay won't it?