#include <Servo.h>
int servo = 3;
int potmeter = A5;
float val = 0;
Servo myServo;
void setup() {
Serial.begin(9600);
pinMode(potmeter, INPUT);
myServo.attach(servo); // attaches the servo on pin 9 to the servo object
}
void loop() {
val = analogRead(potmeter); // reads the value of the potentiometer (value between 0 and 1023)
float mapval = map(val, 0, 1023, 0, 180); // scale it to use it with the servo (value between 0 and 180)
myServo.write(mapval); // sets the servo position according to the scaled value
// waits for the servo to get there
}