#include <Servo.h>
Servo myServo; // Create a Servo object
int servoPin = 9; // Define the pin where the servo is connected
void setup() {
myServo.attach(servoPin); // Attach the servo to the specified pin
Serial.begin(9600);
// Attach the servo to the specified pin
// Initialize Serial communication at 9600 baud
}
void loop() {
int angle = 30;
myServo.write(angle); // Move servo to 30 degrees
Serial.println(angle); // Print the angle to the serial monitor
delay(100);
angle = 60;
myServo.write(angle); // Move servo to 90 degrees
Serial.println(angle); // Print the angle to the serial monitor
delay(100); // Wait for 1 second // Wait for 1 second
angle = 90;
myServo.write(angle); // Move servo to 90 degrees
Serial.println(angle); // Print the angle to the serial monitor
delay(100); // Wait for 1 second
angle = 60;
myServo.write(angle); // Move servo to 90 degrees
Serial.println(angle); // Print the angle to the serial monitor
delay(100);
angle = 30;
myServo.write(angle); // Move servo to 30 degrees
Serial.println(angle); // Print the angle to the serial monitor
delay(100);
angle = 0;
myServo.write(angle); // Move servo to 30 degrees
Serial.println(angle); // Print the angle to the serial monitor
delay(100);
}
FPS: 0
Power: 0.00W
Power: 0.00W