#include <Servo.h>
Servo myservo;
int deg = 0;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32!");
pinMode(26, INPUT);
myservo.attach(18);
}
void loop() {
// put your main code here, to run repeatedly:
delay(10); // this speeds up the simulation
int reading = digitalRead(26);
Serial.println(reading);
if(reading==1){
for (deg = 0; deg <= 180; deg += 1) {
myservo.write(deg);
delay(15);
}
}
}