#include <Servo.h>
Servo myServo;
int pos = 90;
void setup() {
Serial.begin(9600);
myServo.attach(3); // Attach the servo to pin 3
myServo.write(pos); // Initialize servo position
}
void loop() {
if (Serial.available()) {
char command = Serial.read();
Serial.println(command);
if (command == 'R') { // Use single quotes for char comparison
pos=pos+3;
myServo.write(pos);
delay(1);
} else if (command == 'L') { // Use single quotes for char comparison
pos=pos-3;
myServo.write(pos);
delay(1);
}
}
}