#include "ESP32Servo.h"
const int ledPin = 2;
const int potentiometerPin = 32;
const int servoPin = 4;
Servo servo;
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(potentiometerPin, INPUT);
servo.setPeriodHertz(50);
servo.attach(servoPin);
Serial.begin(115200);
}
void loop() {
int potValue = analogRead(potentiometerPin);
Serial.print("Potentiometer Value: ");
Serial.println(potValue);
if (potValue > 1000) {
digitalWrite(ledPin, HIGH); // Turn on the LED
servo.write(0); // Set servo position to 0 degrees
} else {
digitalWrite(ledPin, LOW); // Turn off the LED
servo.write(180); // Set servo position to 180 degrees
}
delay(100); // Delay for stability
}