Hi ¡¡, I hope you are well I want to make an inquiry I have a small program that allows me to move a robot arm per serial port, each servo has a letter and to move the servomotor you have to enter in the serial port the letter + the degree you want to position and do it! My problem is that I can not save that position in the EEPROM how could I do it? I leave the program and I hope they know how to help
#include<Servo.h>
//Creamos los objetos servo
Servo servo;
Servo servo2;
Servo servo3;
Servo servo4;
Servo servo5;
Servo servo6;
unsigned char c; //Letra del Servo
byte posicion =0; //Posicion del servo
void setup()
{
//Inicializamos los Servos
servo.attach(13);
servo2.attach(12);
servo3.attach(11);
servo4.attach(10);
servo5.attach(7);
servo6.attach(6);
//Inicializamos la comunicacion por Serial
Serial.begin(9600);
Serial.println("xxxxxxxxxBienvenido Usuarioxxxxxxxxxxx");
}
void loop(){
if (Serial.available() >= 1)
{
c = Serial.read();
posicion = Serial.parseInt();
//Hora de mover los servos!
if (c == 'a')
{
Serial.print("Motor1: ");
Serial.println(posicion);
servo.write(posicion);
delay(10);
}
else if (c == 'b')
{
Serial.print("Motor2: ");
Serial.println(posicion);
servo2.write(posicion);
delay(10);
}
else if (c == 'c')
{
Serial.print("Motor3: ");
Serial.println(posicion);
servo3.write(posicion);
delay(10);
}
else if ( c == 'd')
{
Serial.print("Motor4: ");
Serial.println(posicion);
servo4.write(posicion);
delay(10);
}
else if ( c == 'e')
{
Serial.print("Motor5: ");
Serial.println(posicion);
servo5.write(posicion);
delay(10);
}
else if (c == 'f')
{
Serial.print("Motor6: ");
Serial.println(posicion);
servo6.write(posicion);
delay(10);
}
}
}