#include <ESP32Servo.h>
Servo myServo;
const int potPin = 35; // Analog pin for potentiometer
const int servoPin = 5; // PWM pin for servo
void setup() {
Serial.begin(115200);
myServo.attach(servoPin); // attach servo to pin
}
void loop() {
int potValue = analogRead(potPin); // Read potentiometer (0-4095 on ESP32)
int angle = map(potValue, 0, 4095, 0, 180); // Map to 0-180 degrees
myServo.write(angle); // Move servo
Serial.print("Pot: "); Serial.print(potValue);
Serial.print(" -> Angle: "); Serial.println(angle);
delay(100);
}
Loading
esp32-s3-devkitc-1
esp32-s3-devkitc-1