/*   Serial communication with the Arduino 
  *   using any serial communication application
  *   (Incoming numbers should be between 1-10)
  *   Setup: - Connect a servo to +, gnd and digital pin 9 
  * -------------------------------------------------------*/
#include <Servo.h>              // Arduino library for servo motors

int pos = 0;        // variable to store the servo position 
byte inByte;        // variable for reading serial port
int servoPin = 9;   // variable for servo pin number

Servo myservo;  // create servo object to control a servo 
                // a maximum of eight servo objects can be created 

 void setup(){
    Serial.begin(9600);
    myservo.attach(servoPin);          // attaches the servo on pin 6 to the servo object
 }

void loop(){
    // Input serial information:
    if (Serial.available() > 0){
       inByte = Serial.read();
       pos = map(inByte, 0, 10, 1, 180);   // scale 0-10 to 1-180
       myservo.write(pos);                 // tell servo to go to position
       delay(10);                         
       }
 }