 
 void sleep(uint8_t sleepTime) {
 
-  while(watchdog_counter++ < sleepTime) {
+  do {
     set_sleep_mode(SLEEP_MODE_PWR_DOWN);             // select the watchdog timer mode
     sleep_enable();                                  // enable the sleep mode ready for use
     sleep_mode();                                    // trigger the sleep
     sleep_disable();                                 // prevent further sleeps 
-  }
-  watchdog_counter = 0;
+  } while(watchdogCounter < sleepTime);
+  
+  watchdogCounter = 0;
 
 }
 
 ISR(WDT_vect) {
-  watchdog_counter++;
+  watchdogCounter++;
 }
 
 

//--------------------------------------------------------------------------------------------------
// Sleep Configuration 
//-------------------------------------------------------------------------------------------------
// 0=16ms, 1=32ms,2=64ms,3=128ms,4=250ms,5=500ms
// 6=1 sec,7=2 sec, 8=4 sec, 9= 8sec
void setup_watchdog(int sleepMode) {

  byte sleepByte;
  if (sleepMode > 9 ) sleepMode=9;
  sleepByte = sleepMode & 7;
  if (sleepMode > 7) sleepByte |= (1<<5);
  sleepByte |= (1<<WDCE);


  sinit();
#endif

  rf12_initialize(myNodeID,freq,network);  // Initialize RFM12 with settings defined above 
  rf12_sleep(0);                           // Put the RFM12 to sleep
  PRR = bit(PRTIM1);                       // only keep timer 0 going
  ADCSRA &= ~ bit(ADEN); 
  bitSet(PRR, PRADC);                      // Disable the ADC to save power
  setup_watchdog(6);

}

