   //          )
   //);
   pinMode(LEDpinA,OUTPUT); digitalWrite(LEDpinA,0);
-  pinMode(AlarmButton,INPUT); 
-  pinMode(TimeButton,INPUT);
+  pinMode(AlarmButton,INPUT_PULLUP); 
+  pinMode(TimeButton,INPUT_PULLUP);
   pinMode(RewButton,INPUT); 
   pinMode(FwdButton,INPUT); 
   pinMode(OffButton,INPUT);
+  encoder = new ClickEncoder(ENCODER_PIN0, ENCODER_PIN1);
   timer.initialize(timerPeriod);
   timer.pwm(LEDpinA, 0); //set up pin 9
   matrix.begin(0x70);
   display_todd();
+  //while (!eeprom.isPresent()) { delay(1); }
   readBrightnessFromEEPROM();
   matrix.setBrightness(matrixBrightness); // 0-15
   readSunDownDeltaFromEEPROM();
   updateClockTime(true);
   updateCurrentTime(true);
-  if (!readAlarmTimeFromEEPROM()) {    
-    alarmTime = ClockTime(5,45);
-  }
+  readAlarmTimeFromEEPROM();
   updateStartTime();
 }
 

unsigned long synchronized_clock_millis;
ClockTime synchronized_clock_time;
ClockTime current_clock_time;

bool readAlarmTimeFromEEPROM() {
  if (eeprom.isPresent()) {

  unsigned long modeActive = millis();
  bool normalExit = true;
  while (debounceDigitalRead(AlarmButton)==HIGH) {
    int16_t encoderDelta = encoder->getValue();
    updateAlarm(encoderDelta);
    modeActive = millis();
    if (static_cast<unsigned long>(millis() - modeActive) > modeInactivePeriod) {
      normalExit = false;
      break;
