#include <ESP32Servo.h>
#define SERVO_PIN 15 // ESP32 pin GPIO15 connected to servo motor
#define LED_PIN 13 // LED pin connected to GPIO13
Servo myServo;
void setup() {
myServo.attach(SERVO_PIN); // attaches the servo on ESP32 pin
pinMode(LED_PIN, OUTPUT); // set LED pin as output
}
void loop() {
// Your original code rotated the servo based on the light sensor reading.
// Since the light sensor is removed, you can simply rotate the servo here.
rotateServo(90); // rotate servo to 90 degrees
digitalWrite(LED_PIN, LOW); // turn on LED
delay(1000); // You can adjust the delay based on your needs
rotateServo(0); // rotate servo to 0 degrees
digitalWrite(LED_PIN, HIGH); // turn off LED
delay(1000); // You can adjust the delay based on your needs
}
void rotateServo(int angle) {
myServo.write(angle);
delay(1000); // Give the servo some time to reach the desired position
}