#include <Servo.h>
Servo myservo; // class object is created
int potPin = A0; // potPin (A0) takes the analog value from potentiometer
void setup()
{
myservo.attach(9); // servo control pin (instructions to servo will be given from this)
}
void loop()
{
int potVal = analogRead(potPin); // analog value is read from the potPin
int angle = map(potVal, 0, 1023, 0, 180); // 10 bit op data from potVal will be mapped to angle
myservo.write(angle); // the angle will now be sent as an ip to the servo
delay(15); // a delay of15 milli secs
}