#include <Servo.h> // import servo library
Servo myservo;
int servoPin = 3; // pin used for servo
int potPin = 0; // potentiometer pin
int potVal; // potentiometer value
void setup() {
// put your setup code here, to run once:
myservo.attach(servoPin);
}
void loop() {
// put your main code here, to run repeatedly:
potVal = analogRead(potPin); // get the value of potentiometer
potVal = map(potVal, 0, 1023, 0, 180); // scale value to use it for servo
myservo.write(potVal); // set servo position
delay(15); // delay 15 ms
}