int Servopin=5;
int angle=0;
void setup() {                
  Serial.begin(9600);
  pinMode(Servopin,OUTPUT); 
}
void loop() {
  //sensorValue = analogRead(A0);
  //angle=sensorValue/1023.0*180.0;
  //delay(100);
  if (Serial.available() > 0) 
  { angle = Serial.read();
    delay(100);
    Serial.println(angle);
     moveangle(Servopin,angle);
   }  
    
}
void moveangle(int Servopin,int angle)
{
int pulsewidth=(angle*11)+500;//change the angle to 500-2480us pulsewidth
digitalWrite(Servopin,HIGH);
delayMicroseconds(pulsewidth);
digitalWrite(Servopin,LOW);
delay(20-pulsewidth/1000);
}
