#include <Servo.h>
Servo servo;
char buf[4];
void setup(){
Serial.begin(9600);
Serial.setTimeout(11);
servo.attach(9);
}
void loop(){
Serial.readBytes(buf, 3);
if (strlen(buf) > 0){
Serial.println(atoi(buf));
servo.write(atoi(buf));
}
for (byte i = 0; i < 4; i++) buf[i] = NULL;
}
This is exactly the code I used for controlling a servo from the Serial Monitor. In a simple code like this, the time I take to type the characters does not matter. I'm sure PaulS's code would be better. I'll need to wait until next Saturday to try it.