 void loop() {
     // TO DO
     test();
-}
+
+    if(WDT_FLAG == TRUE){
+        WDT_FLAG = FALSE;
+    }
+}


ISR(WDT_vect){
    // After interupt, the script goes here
  wdt_disable();  // disable watchdog
}

void sleep(){  
  // This is how we sleep
  MCUSR = 0;                          // reset various flags
  WDTCSR |= 0b00011000;               // see docs, set WDCE, WDE
  WDTCSR =  0b01000000 | 0b100001;    // set WDIE, and appropriate delay
// sleep bit patterns:
//  1 second:  0b000110
//  2 seconds: 0b000111
//  4 seconds: 0b100000
//  8 seconds: 0b100001
  wdt_reset();
  set_sleep_mode (SLEEP_MODE_PWR_DOWN);  
  sleep_mode();            // now goes to Sleep and waits for the interrupt
  } 

float* readVoltage(){
    static float voltages[4] = {0, 1, 0, 0};
    #if TEST
        serialOut("readVoltage");
        for(int i=0; i<NUM_SOURCES; i++){
            voltages[i] = 13.8+i;
        }
        //return voltages;
    #endif

    for(int i=0; i<NUM_SOURCES; i++){
        voltages[i] =  analogRead(VOLT_PIN[i]) * VOLT_MULTI[i];
    }
    return voltages;
}//readVoltage


    pinMode(RED_LED_PIN, OUTPUT);
    pinMode(GREEN_LED_PIN, OUTPUT);

    //Using an external voltage reference for increased accuracy
    analogReference(EXTERNAL);
    analogRead(0); //To help settle the ADC before taking readings

    // WDT setup
    cli(); //disable interrupts
    wdt_reset();
    // Enter 'Config mode'
    WDTCSR |= (1<<WDCE) | (1<<WDE);

    // Set interupts, reset on timeout, last 4 do time (1001 is 8sec)
    WDTCSR = (1<<WDIE) | (0<<WDE) | (1<<WDP3) | (0<<WDP2) | (0<<WDP1) | (1<<WDP0);

    sei(); //enable interupts
  

#if !(TEST)
    // initialize the SD card
