#include <Servo.h>
Servo myservo;
int servo = 5;
String command;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(servo, OUTPUT);
myservo.attach(9);
Serial.println("Command:");
}
void loop() {
// put your main code here, to run repeatedly:
if(Serial.available()>0){
command = Serial.readString();
command.trim();
Serial.println("Command:");
};
if(command == "on"){
myservo.write(0);
delay(1000);
myservo.write(180);
delay(1000);
}
if(command == "off"){
myservo.write(0);
}
}