#include <ESP32Servo.h>
Servo myservo;
int servoPin = 2;
int potPin = 4;
int ADC_Max = 4096;
int val;
void setup() {
Serial.begin(9600);
myservo.setPeriodHertz(50);
myservo.attach(servoPin, 500, 2400);
}
void loop() {
val = analogRead(potPin);
val = map(val, 0, ADC_Max, 0, 180);
Serial.println(val);
myservo.write(val);
delay(200);
}