int potpin = 0; // analog pin used to connect the potentiometer
int val; // variable to read the value from the analog pin
void setup() {
pinMode(10,OUTPUT); // attaches the servo on pin 9 to the servo object
}
void loop() {
val = analogRead(potpin);
val = map(val,0,1023,0,255); // reads the value of the potentiometer (value between 0 and 1023)
analogWrite(10,val);
}