EEPROM, writing and reading from any position

Hey guys, someone please enlighten me, I have the following problem. I’m reading from a keyboard some type char values, and I’m saving in EEPROM and if it works. doing something like this,

for (int i = 0; i <= 3; i ++) // as equals cn cl, then keep the value of the eeprom memory cl
{
EEPROM.write (i, cl );

  • Serial.print (“cl”);*
    _ Serial.println (cl );_
    * }*
    * for (int i = 0; i <= 3; i ++) // Now, read the value of cl saved in EEPROM and is assigned to co.*
    * {*
    _ co = EEPROM.read (i);
    * Serial.print (“co”);
    Serial.println (co );
    }
    Now I’m trying to save another value in another position of the EEPROM memory, for example:
    for (int i = 4; i <= 7; i ++) // as (cn) is equal to cl, then I store the value in memory eeprom cl
    {
    EEPROM.write (i, cl );
    Serial.print (“cl”);
    Serial.println (cl );
    }*

    The EEPROM outliers throws me when I’m trying to read from that position.
    I have almost no experience working with the EEPROM. Any suggestions or advice from you, not hurt.
    Thank You._

The EEPROM outliers throws me when I’m trying to read from that position.

? ? ?

The intent of your sketch and the variable names and assignments are confusing, but I’m not sure why you are having trouble writing and reading the first 8 registers (0-7 of the eeprom). If you continue to post code, please post complete code, use auto format, and post your code within the code tags from the tool bar. Its a scroll with <>.

#include <EEPROM.h>
char c1 = 65; //"A"
char co;
char cn;

void setup(){
  Serial.begin(9600);
  for (int i = 0; i <= 3; i ++) 
  {
    EEPROM.write (i, c1 );
    Serial.print ("c1 ");
    Serial.println (c1 );
  }
  for (int i = 0; i <= 3; i ++) // Now, read the value of cl saved in EEPROM and is assigned to co.
  {
    co = EEPROM.read (i);
    Serial.print (i);
    Serial.print (" co=");
    Serial.println (co );
  }


  for (int i = 4; i <= 7; i ++) // as (cn) is equal to cl, then I store the value in memory eeprom cl
  {
    EEPROM.write (i, c1 );
    Serial.print ("c1 ");
    Serial.println (c1);
  }

  for (int i = 4; i <= 7; i ++) // Now, read the value of cl saved in EEPROM and is assigned to co.
  {
    cn = EEPROM.read (i);
    Serial.print (i);
    Serial.print (" cn=");
    Serial.println (cn );
  }
}
void loop(){
}