#include <ESP32Servo.h>
const int servoPin = 18;
Servo servo;
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
servo.attach(servoPin, 500, 2400);
}
int pos = 0;
void loop() {

 for (pos = 0; pos <= 180; pos += 1) {
 servo.write(pos);
 Serial.println(pos);
 delay(20);
 }
 for (pos = 180; pos >= 0; pos -= 1) {
 servo.write(pos);
 Serial.println(pos);
 delay(20);
 }
}