#include <ESP32Servo.h>
Servo myservo;
int potpin = 35; // analog pin used to connect the potentiometer
int val; // variable to read the value from the analog pin
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
Serial.println("hassen");
myservo.attach(21);
pinMode(potpin, INPUT);
}
void loop() {
val = analogRead(potpin);
Serial.println(val); // reads the value of the potentiometer (value between 0 and 1023)
val = map(val, 0, 1023, 0, 180); // scale it to use it with the servo (value between 0 and 180)
myservo.write(val);
}