#include <ESP32Servo.h>
const int servoPin = 18;
const int potentiometerPin = 34;
Servo servo;
void setup() {
servo.attach(servoPin);
}
void loop() {
// Read the value from the potentiometer
int potValue = analogRead(potentiometerPin);
// Map the potentiometer value to the servo position (0-135 degrees)
int pos = map(potValue, 0, 4095, 0, 135);
// Move the servo to the mapped position
servo.write(pos);
// Delay for smoother servo movement
delay(15);
}