The Code
#include <Servo.h>
// create servo object
Servo motor;
void setup()
{
motor.attach(13);
}
void loop()
{
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
// Convert the analog reading (which goes from 0 - 1023) to an angle (0 - 180 degrees):
float angle = sensorValue * (180 / 1023.0);
// print out the value you read:
motor.write(angle);
delay(250);
}