Reading and writing to EEPROM

Hi,

I am trying to save an int to the EEPROM. This is a calibration number which I am hoping to read on any future power-ups.
From what I gathered, it is not possible to write an into to one EEPROM address. Is there a way that I can split this int into two bytes and save in two addresses?

Note: The int is generated from analogRead() of a pin.

Thanks, Micheal.

Have a look at the lowByte() and highByte() functions for a simple way to split the int into 2 bytes which you can then write to 2 EEPROM locations.

Have a look at this example https://www.arduino.cc/en/Tutorial/EEPROMWrite

Depending on the precision you need, I often divide ints to fit into a byte then write the byte to eeprom. Go the other way to retrieve data from eeprom. Just a thought.

Bill

From what I gathered, it is not possible to write an into to one EEPROM address. Is there a way that I can split this int into two bytes and save in two addresses?

The EERPOM library can read and write int's. You provide the starting address for where you want to store/read the data. It will automatically use two EEPROM bytes to store the int.

Use: EEPROM.put() and EEPROM.get()

My signature also has a link to detailed information of the whole library.