#include ; // Include the ESP32Servo.h library for controlling the servo Servo myservo; // Create an object of type Servo void setup() { myservo.attach(9); // Connect the servo to GPIO pin 9 } void loop() { // Move the servo to the 0-degree position myservo.write(0); // Set the servo position to 0 degrees delay(1000); // Wait for 1 second // Move the servo to the 180-degree position myservo.write(180); // Set the servo position to 180 degrees delay(1000); // Wait for 1 second }