#include <ESP32Servo.h>
const int potPin = 12;
const int servoPin = 14;

Servo myservo;

void setup() {
  Serial.begin(115200);
  myservo.attach(servoPin);
  Serial.println("Hello, ESP32!"); 
}

void loop() {
  // Maximim turning allowed is 40 degrees

  int val= analogRead(potPin);  
  val = map(val, 0, 4095, 45, 135);     // scale it to use it with the servo (value between 0 and 180)
  myservo.write(val);
  delay(15); 
}