 			break;
 
 		case ERROR_MODE:
+			if (oldFsmState != fsmState)
+			{	
+				display.writeMessage("ERRO");
+				Serial.println("Error detected, disabling buttons.");
+				Serial.println("Error detected, disabling RTC alarm.");
+				disableRtcAlarm();
+			}
+			break;
+
 		default:
 			break;
 	}

	// save alarm setting to parts of SRAM, easier retrieval
	RTC.sramWrite(ALARM_H_ADDR, hour);
	RTC.sramWrite(ALARM_M_ADDR, minute);
}

// ---------------------- //

	setSyncProvider(RTC.get);
	setSyncInterval(2);
	if(timeStatus()!= timeSet) 
	{
		Serial.println("Unable to sync with the RTC");
	} else
	{
		Serial.println("RTC has set the system time"); 
		fsmState = ERROR_MODE;
	}
	
	pinMode(ALARM_PIN, INPUT_PULLUP);
	setRtcAlarm(8,30);
