// Include the servo library:
#include "Servo.h"
// Create a new servo object:
Servo myservo;
// Define the servo pin:
#define servoPin 9
void setup() {
// Attach the Servo variable to a pin:
myservo.attach(servoPin);
}
void loop() {
//Get reading from Potentiometer
int rot=analogRead(A0);
//Converting reading from Potentiometer to value in the range 0-180
float angle = rot * (180 / 1023.0);
//Send Angle to Servo
myservo.write(angle);
}