When the Arduino starts up I am reading values from the EEPROM to get the status before the Arduino did shut down the last time, i.e based on the value in the EEPROM I am trying to restore the state before the Arduino did shut down.
How do I handle the situation where I start up the Arduino for the very first time? In this case the Arduino never ran before and therefore never wrote any values to the EEPROM. So what I would read is just some random value, i.e. whatever the previous program did write to the EEPROM.
Thinking about it, maybe the entire EEPROM is reset to 0xff each time a new program is downloaded to the Arduino. So assume I store the program ‘version’ at EEPROM address 0 and the program version is <0xff. So if I read a value <0xff I know my program was ran before and I can restore the previous state. However, if the value is 0xff then I know the program never ran before and I set the value to a default value.