Help to recover data from two servos in the EEPROM

Good morning I have a problem with a code that I tried to move two servomotres my problem is that for example in the first 3 boxes I keep the servo1 degrees and in the other 3 boxes I keep the values of the servo 2
but at the time of calling them instead of qeu run the valroes of servo 1 and after the two both are executed at the same time¡¡¡ how could ahcer to correctly retrieve the values qeu keep ???

#include<Servo.h>
#include <EEPROM.h>
//Creamos los objetos servo
Servo servo;
Servo servo2;

unsigned char c; //Letra del Servo
int posicion; //Posicion del servo

int valor[5];  //valor para almacenar lo del servo1
int valor2[5]; //valor2 para el servo2

int j[20]; // array para la EEPROM

void setup()
{
  //Inicializamos los Servos
    servo.attach(12);
    servo2.attach(11);

  //Inicializamos la comunicacion por Serial
  Serial.begin(9600);

  Serial.print(" \n");
  Serial.println("xxxxxxxxxBienvenido Usuarioxxxxxxxxxxx");
  Serial.println("  AUTOMATA Codigo1 by: Daniel Juarez");
}

void loop() {

  if (Serial.available())
  {

    c = Serial.read();
    posicion = Serial.parseInt();
    
    // movemos el servo 1 o el dos y automaticamente el valor que se le dio se guarda
    // se introduce la letra del servo + los grados para moverlo
    if (c == 'a')
    {
     
      Serial.print("Motor1: ");
      Serial.println(posicion);
      servo.write(valor[0]);
      delay(10);
      valor[0] = posicion;
  EEPROM.write(j[0], valor[0]);
  Serial.print("Guardo en la posicion ");
  Serial.print(j[0]);
  Serial.print("\t");
  Serial.println(valor[0]);
 
 
   j[0]++;
   valor[0]++;
  
    }
    
    else if (c == 'b')
    {
      
      Serial.print("Motor2: ");
      Serial.println(posicion);
      servo2.write(posicion);
      delay(10);
      valor2[0] = posicion;
   EEPROM.write(j[0], valor2[0]);
   Serial.print("Guardo en la posicion ");
   Serial.print(j[0]);
   Serial.print("\t");
   Serial.println(valor2[0]);
    
      j[0]++;
      valor2[0]++;
     
    }
   /* 
    else if (c == 'm')
    {
      graba();
    } */
    
    else if (c == 'z') 
    {
    automata();  //lee los datos guardados y hace mover los servos
    } 
    
    else if (c == 'x') 
    {
    borrar();       //boorra los datos de la EEPROM
    }

  }

}
/*
void graba() {

  EEPROM.write(j[0], valor);
  Serial.print("Guardo en la posicion ");
  Serial.print(j[0]);
  Serial.print("\t");
  Serial.println(valor);
  j[0]++;

  EEPROM.write(j[0], valor2);
  //Serial.print("Guardo en la posicion ");
  //Serial.print(j[0]);
  //Serial.print("\t");
  Serial.println(valor2);
   j[0]++;
   
}
  */ 

void automata() {

 Serial.println("EJECUTANDO MEMORIA¡¡¡¡¡");
  delay(10);
  int i = 0;
  
for (i = 0; i < 10; i++)
  {
 valor[0] = EEPROM.read(i);
 valor2[0] = EEPROM.read(i);
 
 Serial.println( EEPROM.read(i));

 servo.write(valor[0]);
 delay(500);
 servo2.write(valor2[0]);
 delay(500);
 
    }

}

void borrar() {

  pinMode(13, OUTPUT);
  Serial.println("Borrando Memoria¡¡¡¡¡");

  for (int i = 0 ; i <100; i++) {
    EEPROM.write(i, 0);
    /*EEPROM.length()*/
  }
  digitalWrite(13, HIGH);
  Serial.println("Memoria Borrada¡¡¡¡¡");

}

Why do you have an array, j, with 20 elements, when you only use the first element in the array? Why is the array given such a generic name?

I think that, in the future, I'll just call you person, since you ARE a person. No need to get fancy with meaningful names, person, when any old name will do.

You have an array of values, too. Two of them, actually. You only ever use the first value in each array.

What it appears that you want to do is increment the index into the array, NOT the value in the first position in array.

I have a feeling that when you write:

      j[0]++;
      valor2[0]++;

you want to increment the array INDEXes i.e. the 0 in the brackets. But that's not what you're doing.

Steve

Well maybe - its not clear.

MarkT:
Well maybe - its not clear.

You're right. That's why it's "a feeling" and not a fact.

Steve

PaulS:
Why do you have an array, j, with 20 elements, when you only use the first element in the array? Why is the array given such a generic name?

I think that, in the future, I'll just call you person, since you ARE a person. No need to get fancy with meaningful names, person, when any old name will do.

You have an array of values, too. Two of them, actually. You only ever use the first value in each array.

What it appears that you want to do is increment the index into the array, NOT the value in the first position in array.

I gave it the name of "J" for giving it to me but it is not a final code this is a beta phase
I explain with J what I do is move from 0 to 19 in the eeprom osea saving from 0 to 19 in the eeprom values that are the degrees that you use to move the servo 1 or 2
now .... at the time of reading the eeprom I do not recognize the order that I moved the engines run simultaneously and I do not want that I want to keep the values of the servos in the order I want and after that when I read the eeprom recognize if that value I read is of servant 1 or 2 and make him move that I want that is what keeps me stuck

I explain with J what I do is move from 0 to 19 in the eeprom osea saving from 0 to 19 in the eeprom values

That would be the case if a value other than 0 ever appeared between the square brackets. As it doesn't, you might as well make j a scalar variable (non-array).

If you want to store values are each of the 20 positions in the array, you have to use all the values from 0 to 19 in the square brackets, or use a variable that takes on all the values from 0 to 19.

PaulS:
That would be the case if a value other than 0 ever appeared between the square brackets. As it doesn't, you might as well make j a scalar variable (non-array).

If you want to store values are each of the 20 positions in the array, you have to use all the values from 0 to 19 in the square brackets, or use a variable that takes on all the values from 0 to 19.

ie the value and value vectors2 that I have in my code that I use for the servomotors do not move from the first position?
how can I solve my code then give me ideas and thank you but if I put an example with a code I would understand much better
can you give me an example please if it is not much trouble ??? because if I manage to make the two servo motors move in the corresponding angles in the order they were saved would have a huge advance that would help me to almost complete my thesis because this problem that I have prevented me from completing my thesis