#include <Servo.h>
Servo servo1;
int potpin = 0; // analog pin used to connect the potentiometer
int val; // variable to read the value from the analog pin
void setup() {
// put your setup code here, to run once:
servo1.attach(3); // attaches the servo on pin 9 to the servo object
}
void loop() {
// put your main code here, to run repeatedly:
val = analogRead(potpin); // reads the value of the potentiometer
val = map(val, 0, 1023, 0, 180); // scale it to use it with the servo
servo1.write(val); // sets position to the scaled value
delay(15); // waits for the servo to get there
}