#define myservo 5 // the pin the servo is on void setup() { // put your setup code here, to run once: Serial.begin(115200); Serial1.begin(115200); pinMode(myservo, OUTPUT); } void loop() { // put your main code here, to run repeatedly: if (Serial1.available()) { Serial.println(Serial1.readString()); if (Serial1.readString().equals("turn0")); { for (int x = 0; x < 50; x++) { digitalWrite(myservo, HIGH); delayMicroseconds(500); digitalWrite(myservo, LOW); delayMicroseconds(19500); } } if (Serial1.readString().equals("turn1")); { for (int x = 0; x < 50; x++) { digitalWrite(myservo, HIGH); delayMicroseconds(2500); digitalWrite(myservo, LOW); delayMicroseconds(17500); } } } }