#include <ESP32Servo.h>
Servo myservo;
int pos = 0;
void setup()
{
Serial.begin(9600);
while (!Serial);
Serial.println("-------------------------");
delay(1000);
Serial.println("ARos loaded succesfully");
Serial.println("-------------------------");
myservo.attach(5);
Serial.println("Comand input online, write command to perform action");
Serial.println("-------------------------");
}
void loop() {
if (Serial.available() > 0)
{
String commend = Serial.readStringUntil('\n');
if (commend == "Right" || commend == "right" || commend == "يمين")
{
Serial.println("-----------------------");
Serial.println(commend);
if (pos == 0 ) {
pos = -50;
} else if (pos == 50) {
pos = 100;
}
myservo.write(pos);
Serial.read();
Serial.read();
}
if (commend == "Left" || commend == "يسار" || commend == "left")
{
Serial.println("----------------");
Serial.println(commend);
if (pos == 0 ) {
pos = 50;
} else if (pos == -50) {
pos = 100;
}
myservo.write(pos);
Serial.read();
Serial.read();
}
}
}