#include <Servo.h>  
Servo myservo;  // create servo object to control a servo 
                // a maximum of eight servo objects can be created 
int pos = 0;    // variable to store the joystick value 
int angle = 0;  // variable to store the servo angel 
void setup() 
{ 
     myservo.attach(5);  // attaches the servo on pin 5 to the servo object 
     myservo.write(90);
} 
 
 
void loop() 
{ 
      pos=analogRead(A5);
      if(pos==1023){
        myservo.write(90);
        delay(200);
        }
      else{
      int angle = map(pos,200,800,0,180);
      myservo.write(angle);              // tell servo to go to position in variable 'angle' 
      delay(20);                       // waits 15ms for the servo to reach the position 
      }
} 
