#include <Servo.h>
#define PIN_SERVO 9
#define PIN_CONTROL A3
int val;
Servo myservo;
int pos = 1;
void setup() {
myservo.attach(9);
pinMode(PIN_CONTROL, INPUT);
Serial.begin(9600);
}
void loop() {
val = analogRead(PIN_CONTROL);
val = map(val, 0, 1023, 1, 180);
val = constrain(val, 1, 180);
myservo.write(val);
Serial.println(val);
delay(15);
}