#include <ESP32Servo.h>
int sensorPin = 14;
int motorPin = 21;
int indicatorPin = 25;
int sensorValue;
int operationMode;
Servo myMotor;
void setup() {
Serial.begin(9600);
pinMode(indicatorPin, OUTPUT);
pinMode(sensorPin, INPUT);
myMotor.attach(motorPin, 500, 2400);
}
void loop() {
readSensor();
controlDevice();
}
void readSensor() {
sensorValue = analogRead(sensorPin);
if (operationMode != 1) {
if (sensorValue < 400) {
digitalWrite(indicatorPin, HIGH);
myMotor.write(0);
} else {
digitalWrite(indicatorPin, LOW);
myMotor.write(180); // Adjust the angle as needed
}
}
}
void controlDevice() {
// Add your device control logic here if needed
}