You are probably not running the latest Arduino release
replace if(isDigit(inChar)) with: if (inChar >= '0' && inChar <= '9')
This version will compile on earlier Arduino releases
// Serial Servo Tester
// Use the Serial Monitor to write a value from 0 to 180
// Set Serial Monitor line ending to Newline
// for writeMicroseconds, use values from 544 to 2400
#include <Servo.h>
Servo myservo; // create servo object to control a servo
String inString;
void setup()
{
Serial.begin(9600);
myservo.attach(9); //the pin for the servo control
Serial.println("Enter angle between 0 and 180 (values from 544 written as Microseconds)");
}
void loop() {
while (Serial.available()> 0) {
int inChar = Serial.read();
if (inChar >= '0' && inChar <= '9')
{
// if the incoming character is a digit, add it to the string
inString += (char)inChar;
}
else
{
// here on the first character that is not a digit
int value = inString.toInt();
if(value >= 544)
{
Serial.print("writeing Microseconds: ");
Serial.println(value);
myservo.writeMicroseconds(value);
}
else
{
Serial.print("writing Angle: ");
Serial.println(value);
myservo.write(value);
}
// clear the string for new input:
inString = "";
}
}
}