I am starting on a new project to create a walking robot using 3 servos, i read Zoomcat's code and changed it is this corect im sort of new to coding arduino
#include <Servo.h>
String readString, servo1, servo2, servo3;
Servo myservo1;
Servo myservo2;
Servo myservo3;
void setup() {
Serial.begin(9600);
myservo1.attach(6);
myservo2.attach(7);
myservo3.attach(8);
Serial.println("three-servo-test-1.0");
}
void loop() {
while (Serial.available()) {
delay(3);
if (Serial.available() >0) {
char c = Serial.read();
readString += c;
}
}
if (readString.length() >0) {
Serial.println(readString);
servo1 = readString.substring(0, 4);
servo2 = readString.substring(4, 8);
servo3 = readString.substring(8, 12);
Serial.println(servo1);
Serial.println(servo2);
Serial.println(servo3);
int n1 = servo1.toInt();
int n2 = servo2.toInt();
int n2 = servo3.toInt();
myservo1.writeMicroseconds(n1);
myservo2.writeMicroseconds(n2);
myservo3.writeMicroseconds(n2);
readString="";
}
}