#include <Servo.h>
Servo servo1;
Servo servo2;
void setup() {
servo1.attach(9); // Attach servo to pin 9
servo2.attach(10); // Attach servo to pin 10
Serial.begin(9600); // Initialize serial communication
Serial.println("Arduino is ready.");
}
void loop() {
if (Serial.available()) {
String command = Serial.readStringUntil('\n'); // Read command from Serial
if (command == "rotate left") {
servo1.write(45);
servo2.write(45); // Rotate servo1
Serial.println("Servos rotated to 45 degrees");
} else if (command == "move up") {
servo2.write(90);
servo1.write(90); // Rotate servo2
Serial.println("Servos rotated to 90 degrees");
}
}
}