#include "ESP32Servo.h"
Servo myservo;
int potpin = 34;
int speed;
int j;
int val;
void setup() {
myservo.attach(19);
Serial.begin(115200);
}
void loop() {
for(j=0;j<=180;j=j+2)
{
speed = analogRead(potpin); // 0 -- 4095
speed= (speed /50);
val = map(j, 0, 180, 0, 180); // var , min var to max var , from angle , to angle
myservo.write(val);
delay(3+1*speed);
Serial.println(val);
}
Serial.println("------ 180 ------");
for(j=180;j>=0;j=j-2)
{
speed = analogRead(potpin); // 0 -- 4095
speed= (speed /50);
val = map(j, 0, 180, 0, 180); // var , min var to max var , from angle , to angle
myservo.write(val);
delay(3+1*speed);
Serial.println(val);
}
}