 }
 
 void setup() {
+  // get saved data from EEPROM
+  EEPROM.get(ADDR_RETIRE_TIME, retire_time);
+  EEPROM.get(ADDR_BRIGHTNESS,  brightness);
+
   // define PWM brightness pin for output
   pinMode(PinBacklight, OUTPUT);
   // set up the LCD's number of columns and rows:
   lcd.begin(16, 2);
   lcd.clear();
-
-  // get saved data from EEPROM
-  EEPROM.get(ADDR_RETIRE_TIME, retire_time);
-  EEPROM.get(ADDR_BRIGHTNESS,  brightness);
+  analogWrite(PinBacklight, brightness);
+
+  // configure clock to use RTC
+  if(! RTC.read(tm)){
+    // RTC isn't working
+    while(true){
+      update_lcd("RTC read error :/", String(millis()/1000));
+      delay(250);
+    }
+  }
+  setSyncProvider(RTC.get);
+  if(timeStatus() != timeSet){
+    // RTC isn't set
+    while(true){
+      update_lcd("Time is not set :/", String(millis()/1000));
+      delay(250);
+    }
+  }
 
   // assemble menu
   mm.add_item(&mi_backlight, &mcb_backlight);

  mm_retirement.add_item(&mi_retirement_day,   &mcb_retirement_day);
}

void loop() {
  lcd_key = read_LCD_buttons();
  switch (lcd_key){
    case btnNONE: {
      break;
    }
    case btnRIGHT: {
      key = "RIGHT";
      brightness += 1;
      if( brightness >= BrightMax ){
        brightness = BrightMax;
      }
      EEPROM.update(ADDR_BRIGHTNESS, brightness);
      break;
    }
    case btnLEFT: {
      key = "LEFT";
      brightness -= 1;
      if( brightness <= BrightMin ){
        brightness = BrightMin;
      }
      EEPROM.update(ADDR_BRIGHTNESS, brightness);
      break;
    }
    case btnUP: {
      key = "UP";
      lcd.display();
      brightness = BrightMax;
      break;
    }
    case btnDOWN: {
      key = "DOWN";
      brightness = BrightMin;
      lcd.noDisplay();
      break;
    }
    case btnSELECT: {
      key = "SELECT";
      break;
    }
  }
  analogWrite(PinBacklight, brightness);

  // assemble first LCD line
  line1 = "";
  line1 = "ADC:" + String(adc_key_in);
  while( line1.length() < 16 - key.length() ){
    line1 = line1 + " ";
  }
  line1 = line1 + key;
  lcd.setCursor(0,0);
  lcd.print(line1);

  // assemble second LCD line
  line2 = "bright:" + String(brightness);
  secs = String(millis()/1000);
  if(RTC.read(tm)){
    secs = "ok!" + String(tm.Second);
  }
  while( line2.length() < 16 - secs.length() ){
    line2 = line2 + " ";
  }
  line2 = line2 + secs;
  lcd.setCursor(0,1);
  lcd.print(line2);
}

 * http://www.amazon.com/gp/product/B0076FWAH8
 * http://www.amazon.com/gp/product/B00LZCTMJM
 */

//#include <Chronos.h>

/* 
 set up for the RTC
