EEPROM Questions

Hi there, Got a few questions, mostly to do with writing, reading, and updating values in EEPROM but also to do with an LCD using liquid crystal.

My problem:
I have 5 values that I need the ability to change with the LCD then write them to EEPROM. On setup I want the EEPROM to update these variables so that they contain the last updated information.

Would I have to call the variables one by one in the setup or is there a possibility for an array?

ex.
Timer1INV = EEPROM.read(address, Timer1IND);

Timer1INV is my main variable thats gonna be used
address is the location in the EEPROM of the variable
Timer1IND is the variable in the EEPROM

Thanks in advance,

  • Matt

You can use an array, but you need to be mindful that read() returns a byte data type. If your data fits within the limits of a byte, just make a 5 element byte array. If something other than a single byte holds the data of interest, take a look at the EEPROM.get() method.

econjack:
You can use an array, but you need to be mindful that read() returns a byte data type. If your data fits within the limits of a byte, just make a 5 element byte array. If something other than a single byte holds the data of interest, take a look at the EEPROM.get() method.

So just clarification one more time.

int i[] = {0, 1, 2, 3, 4}
for (i = 0; i < 5; i = i + 1){
EEPROM.read(i, x);
}

This array would store the values from 5 locations of the EEPROM into 5 locations of X?

x[0]=10

Correct?

This array would store the values from 5 locations of the EEPROM into 5 locations of X?

No.

You are reading bytes. Storing them in an int array is a waste of space.

The read() method takes an address, and returns a value. It does not take two arguments.

The x+1; line is silly, since the result is thrown away.

PaulS:
No.

You are reading bytes. Storing them in an int array is a waste of space.

The read() method takes an address, and returns a value. It does not take two arguments.

The x+1; line is silly, since the result is thrown away.

The x+1 was me overthinking the array and I edited my post hoping before anyone caught it :wink:

You are right, I was looking at the EEPROM.write

Thanks,

  • Matt