#include <ESP32Servo.h>
#define SERVO_PIN 17 // ESP32 pin GPIO17 connected to servo motor
#define LED_PIN_1 14 // LED pin 1 connected to GPIO14
#define LED_PIN_2 12 // LED pin 2 connected to GPIO12
Servo myServo;
void setup() {
myServo.attach(SERVO_PIN); // attaches the servo on ESP32 pin
pinMode(LED_PIN_1, OUTPUT); // set LED pin 1 as output
pinMode(LED_PIN_2, OUTPUT); // set LED pin 2 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_1, LOW); // turn on LED 1
digitalWrite(LED_PIN_2, HIGH); // turn off LED 2
delay(1000); // You can adjust the delay based on your needs
rotateServo(0); // rotate servo to 0 degrees
digitalWrite(LED_PIN_1, HIGH); // turn off LED 1
digitalWrite(LED_PIN_2, LOW); // turn on LED 2
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
}