hi guys need help tring an easy one but cant make it to work
im want to write to eeprom - 3 array[x] one is unsigned long two is int
i dontknow whats the the contect
i tried to make a two for loop
//address will change with +50 from other funcation
EEPROM.put(address, GetData);
EEPROM.put((address+10), GetDData);
EEPROM.put((address+20), GetPData);
for (int i=0 ; i<250; i=i+50 ) {
for (int z = 0 ; z<5 ; z=z+1 ){
EEPROM.get( i ,
EEPROM.put(address, GetData[z] );
EEPROM.get(( i+10 ), GetDData[z] );
EEPROM.get(( i+20 ), GetPData[z] );
}
}
That is a rather convoluted function call. EEPROM.put(addreee, GetData[z]) will write the value in GetData[z] to EEPROM, then return a reference to GetData[z]. The value read from EEPROM address i is then written to GetData[z]. This is assuming the compile does everything in that assumed order.
The put() and get() functions will work with entire arrays, then is no need to write / read each individual element of the array.
But only 3 different arrays. As long as you make sure that the difference between the EEPROM addresses is large enough to hold the number of bytes in each array so that they do not overlap you can save and load whole arrays like this
EEPROM.put(0, Data); //save Data array at 0
EEPROM.put(100, DataX); //save DataX array at 100
EEPROM.put(200, DataXX); //save DataXX array at 200
EEPROM.get(0, Data); //load Data array from 0
EEPROM.get(100, DataX); //load DataX array from 100
EEPROM.get(200, DataXX); //load DataXX array from 200
NOTE that I have deliberately allowed masses of space for each array by using addresses 0, 100 and 200
Just get() the whole array then use the single value from the array in the sketch
Similarly if you change a single value in the array and want to save it just put() the whole array. Any values that have not changed will automatically not be written again. There is also an update() function that does the same thing but the name is more explicit