#include Servo myservo; // create servo object to control a servo char receivedPos; void setup() { Serial.begin(9600); myservo.attach(9); // attaches the servo on pin 9 to the servo object myservo.write(0); // on power on, move servo to central position Serial.println("1: moves to absolute position 0 dregrees"); Serial.println("2: moves to absolute position 45 dregrees"); Serial.println("3: moves to absolute position 90 dregrees"); Serial.println("4: moves to absolute position 135 dregrees"); Serial.println("5: moves to absolute position 180 dregrees"); } void loop() { while(Serial.available()) { String commands = Serial.readString(); // read the incoming data as string Serial.println("I read string: "+ commands); // feedback of data received receivedPos = commands.charAt(0); // convert to char to enable Switch Statement use switch (receivedPos) { case '1': myservo.write(0); break; case '2': myservo.write(45); break; case '3': myservo.write(90); break; case '4': myservo.write(135); break; case '5': myservo.write(180); break; default: break; } } }