#include <Servo.h>
int potpin = 0;
int val = 0;
Servo servo_9;
void setup()
{
servo_9.attach(9, 500, 2500);
}
void loop()
{
// reads the value of the potentiometer (value
// between 0 and 1023)
val = analogRead (potpin);
// scale it to use it with the servo (value
// between 0 and 180)
val = map(val, 0, 1023, 0, 179);
// sets the servo position according to the
// scaled value
servo_9.write(val);
// waits for the servo to get there
delay(15);
}