#include <Servo.h>
Servo myservo; // create servo object to control a servo
void setup() {
myservo.attach(9);
Serial.begin(9600);
}
void loop() {
if (Serial.available() > 0) {
int pos = Serial.parseInt();
Serial.end(); /*end serial communication*/
Serial.begin(9600); /*clear serial buffer*/
myservo.write(pos);
}
}

böyle deneseniz bir. olmazsa Serial.flush() denersiniz