/*#include <Servo.h>
#include <WiFi.h>
const char *ssid = "Wokwi-GUEST";
const char *password = "";
Servo myServo; // Create a Servo object to control the servo motor
void setup() {
Serial.begin(115200);
// Connect to Wi-Fi
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi...");
}
Serial.println("Connected to WiFi");
myServo.attach(9); // Attach the servo to pin 9
}
void loop() {
rotateServo(); // Call the function to rotate the servo
delay(600000); // Wait for 10 minutes (600,000 milliseconds)
}
void rotateServo() {
myServo.write(90); // Rotate the servo to the middle position (90 degrees)
delay(1000); // Wait for a moment
myServo.write(0); // Rotate the servo to the initial position (0 degrees)
delay(1000); // Wait for a moment
}*/
#include <ESP32Servo.h>
Servo myservo; // create servo object to control a servo
// Recommended PWM GPIO pins on the ESP32 include 2,4,12-19,21-23,25-27,32-33
int servoPin = 13;
void setup() {
myservo.setPeriodHertz(50);
myservo.attach(servoPin);
}
void loop() {
myservo.write(0);
delay(2000);
myservo.write(180);
delay(2000);
}