#include <EEPROM.h>
#include <TinyDebug.h>

constexpr uint8_t INDICATOR_CHAR {'@'};
constexpr int EE_BASE_ADDRESS {0};   // Start address of the data storage area

struct exampleData {
  const uint8_t ichar;   // Indicator Character
  char question[85];
  uint8_t value;
};

exampleData writeIt {INDICATOR_CHAR, "The answer of the ultimate question of life, the universe, and everything?", 42 };
exampleData readIt  {INDICATOR_CHAR, "", 0};

//
// Reading pwm data from EEProm
//
void readEEPROM(int eeAddr, exampleData &d) {
  if (EEPROM.read(eeAddr) != d.ichar) {   // Executed if no data has ever been saved.
    EEPROM.put(eeAddr, d);
  } else {
    EEPROM.get(eeAddr, d);   // If data has been saved, read it out.
  }
}

//
// Write pwm data to EEProm
//
void writeEEPROM(int eeAddr, exampleData &d) { EEPROM.put(eeAddr, d); }

void setup() {
  Debug.begin();
  writeEEPROM(EE_BASE_ADDRESS, writeIt);
  readEEPROM(EE_BASE_ADDRESS,readIt);
  Debug.println(readIt.question);
  Debug.println(readIt.value);
}

void loop() {}
ATTINY8520PU