You can try for example this:
#include <avr/sleep.h>
#include <avr/wdt.h>
#define LED 0
volatile boolean on = true;
ISR(WDT_vect)
{
on = !on;
wdt_disable();
}
void myWatchdogEnable(const byte interval)
{
noInterrupts();
wdt_reset();
MCUSR = 0; // reset various flags
WDTCR |= 0b00011000; // see docs, set WDCE, WDE
WDTCR = 0b01000110 | interval; // set WDIE, and appropriate delay
ADCSRA &= ~_BV(ADEN);
set_sleep_mode (SLEEP_MODE_IDLE);
sleep_bod_disable();
interrupts();
sleep_mode();
}
void setup()
{
pinMode (LED, OUTPUT);
}
void loop(){
digitalWrite (LED, on);
if (WDTCR&(1<<WDIE) { //still waiting for WDT interrupts, simply go sleep
sleep_bod_disable();
sleep_mode();
}
else { //WDT interrupt is disabled (from WDT ISR)
myWatchdogEnable (0b000110); // 1 second
}
}