#include Servo myServo; const int servoPin = 9; // the pin the servo is connected to int val = 0; // a value accumulated from data on the serial port int angle = 60; // the current angle of the servo void setup() { Serial.begin(9600); myServo.attach(servoPin); myServo.write(angle); // center the servo } void loop() { if ( Serial.available()) { char ch = Serial.read(); if(ch >= '0' && ch <= '9') // is ch a number? val = val * 10 + ch - '0'; // yes, accumulate the value else if(ch == '-') // is this the minus sign? { angle = angle - val; if(angle < 60) angle = 60; myServo.write(angle); // write the new angle val = 0; } else if(ch == '+') // is this the plus sign? { angle = angle + val; if(angle > 145) angle = 145; myServo.write(angle); // write the new angle val = 0; } } }