#include Servo servo; // Create a servo object to control a servo int position = 90; // Start the servo at the middle position void setup() { servo.attach(7); // Serial.begin(9600); // Initialize serial communication at 9600 bps servo.write(position); // Move servo to start position } void loop() { if (Serial.available() > 0) { char command = Serial.read(); // Read the incoming character switch (command) { case 'L': position = max(0, position - 15); // Decrease position by 15 degrees, not going below 0 servo.write(position); break; case 'R': position = min(180, position + 15); // Increase position by 15 degrees, not exceeding 180 servo.write(position); break; } } }