#include Servo myServo; void setup() { myServo.attach(9); // Attach the servo to pin 9 } void loop() { // Turn left myServo.write(0); // 0 = full speed counterclockwise delay(3000); // Rotate for 3 seconds // Stop myServo.write(90); // 90 = stop delay(1000); // Wait for 1 second // Turn right myServo.write(180); // 180 = full speed clockwise delay(3000); // Rotate for 3 seconds // Stop myServo.write(90); // Stop again delay(1000); // Wait for 1 second }