specific eeprom address

hi guys… im pretty new to all this so excuse my code! :slight_smile:

can i write the content of an array to a specific address to the eeprom?

here is the code i have used to write and read to the first four slots… and it DOES WORK…

void saveCurrentSetting(){ 
  for(int i=0; i<4; i++){
    preset1Vals[i] = currentVals[i];
  }
  for(int i=0; i<4; i++){
    EEPROM.write(i, preset1Vals[i]);
  }
 }


void readIt() { 
  for(int i=0; i<4; i++){
    preset1Vals[i] = EEPROM.read(i);  
  }  
}

but what i would like to do (but cant seem to get it to work) is to write another batch of info to the next 4 slots in the eeprom…

kinda like

 for(int i=4; i<7; i++){
    EEPROM.write(i, preset2Vals[i]);
  }

any help would be appreciated!

Thanks!!!

-Mubo

How did you test it? Not using "readIt", I hope.

errr…

but i =4 while i < 7 does not write four locations does it?

Assuming of course that you have initialised the array in the first place… :wink:

Dave.

@AWOL ... actually yea, i did test it like that..and it seems to be recalling the same info that im writing... is that not the way to do it?

basically what im doing is grabbing the values of a set of pots ... storing them into currentVars, and then when a button is pressed, storing them into preset1Vars...and then writing to the eeprom ..all the vars are output to my lcd so i can see whats going on...

if i run the sketch without readIt() my preset1Vars are all empty... when i run it WITH readIt() my preset1Vars are equal to what i previously saved.

any..if you could elaborate on your comment...it'd be much appreciated!

Thanks! -Rik

You probably mean:

 for(int i=[glow]0[/glow]; i[glow]<4[/glow]; i++){
    EEPROM.write([glow]4 + [/glow]i, preset2Vals[i]);
  }

@drhex ....

thanks! ... worked perfectly!!!