Step 1: Materials
Servo (5volt, really any small size will work)
10k ohm potentiometer
Step 2: Circuit
The servo has three wires, Vcc, ground, and data. Connect Vcc to power, ground to ground, and data to pin 3. The data pin is important because it needs to be a pin with PWM or pulse with modulation control. Not all arduino pins have this capability. On the uno they are marked by a " ~ ".
Connect the potentiometer to power and ground. Connect the third leg to analog pin 5. This creates a variable voltage divider for the arduino to read.
Step 3: Code
#define POT_PIN 5
#define SERVO_PIN 3
Servo myservo; // create servo object to control a servo
myservo.attach(SERVO_PIN); // attaches the servo on pin 9 to the servo object
val = analogRead(POT_PIN); // reads the value of the potentiometer (value between 0 and 1023)
val = map(val, 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 180)
myservo.write(val); // sets the servo position according to the scaled value
delay(15); // waits for the servo to get there
Run that and Viola! You can now control a servo with a potentiometer.