int potpin = A0; // analog pin used to connect the potentiometer
int ledpin = 13;
int val; // variable to read the value from the analog pin
void setup()
{
pinMode(ledpin, OUTPUT);
}
void loop()
{
val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023)
val = map(val, 0, 1023, 500, 5); // scale it to use it with the servo (value between 0 and 180)
digitalWrite(ledpin, HIGH);
delay(val); // waits for the servo to get there
digitalWrite(ledpin, LOW);
delay(val);
}