//Creates a system to open the gate once it detects an object approaching it.
#include <ESP32Servo.h>
#define PIN_POT 26
#define PIN_SERVO 18
Servo myServo;
void setup() {
Serial.begin(9600);
myServo.attach(PIN_SERVO);
}
void loop() {
int analogValue = analogRead(PIN_POT);
int angle = map(analogValue, 0, 1023, 90, 180);
myServo.write(angle);
Serial.print("Analog value: ");
Serial.print(analogValue);
Serial.print(" => Angle: ");
Serial.println(angle);
delay(100);
}