#include <Servo.h>
Servo myServo;
int const potPin = A0;
int potRawVal;
int servoAngle = 0;
void setup() {
// put your setup code here, to run once:
myServo.attach(9);
Serial.begin(9600);
myServo.write(servoAngle);
}
void loop() {
// put your main code here, to run repeatedly:
delay(250);
potRawVal = analogRead(potPin);
Serial.print("Raw servo value: ");
Serial.println(potRawVal);
servoAngle = map(potRawVal, 0, 1023, 0, 179);
Serial.print("Servo angle: ");
Serial.println(servoAngle);
myServo.write(servoAngle);
delay(250);
}