#include <Servo.h>
Servo myservo;
int potenpin = 0; //analog potentiometer pin
int pos; //variable to read analog potentiometer pin
void setup() {
myservo.attach(9);
}
void loop() {
pos = analogRead(potenpin); //reads from analog potentiometer pin
pos = map(pos, 0, 1023, 0, 180); //(scale 0-->1023) (angle 0-->180)
myservo.write(pos);
delay(15);
}