// potent is on analog pin 0
// servo on digital pin 9
#include <Servo.h>
Servo servo;
int potentiometerVal;
int discreteVal;
void setup() {
Serial.begin(115200);
// pin, min, max pluse widths
servo.attach(9, 500, 2500);
// setup to read potentiometer input
pinMode(A0, INPUT );
}
void loop() {
// get the input from potentiometer
potentiometerVal = analogRead(A0);
// maps the 0-1023 of the ADC to 0-180 degrees for the servo
discreteVal = map(potentiometerVal, 0, 1023, 0, 180);
// tell servo to move the given degree
servo.write(discreteVal);
Serial.println(discreteVal);
delay(100);
}