You might want to look at Serial.ReadBytesUntil().
And then atoi().
Here is my loop code at the moment:
void loop() {
Serial.print("Send an integer value between 1300 and 1700 ");
Serial.println("microseconds to test speed...");
while (Serial.available() == 0);
pulseWidthInput[0] = Serial.readBytesUntil(not sure what to put here);
Serial.println(pulseWidthInput);
int pulseWidth = atoi(pulseWidthInput);
if (pulseWidth >= 1300 && pulseWidth <= 1700) {
Serial.print("Testing speed at: ");
Serial.println(pulseWidth);
leftServo.writeMicroseconds(pulseWidth);
rightServo.writeMicroseconds(pulseWidth);
delay(6000);
leftServo.writeMicroseconds(1500);
rightServo.writeMicroseconds(1500);
}
The Arduino reference article isn't too specific and doesn't include an example of Serial.readBytesUntil(). How exactly should I go about with the parameters of this function?