#include "Arduino.h"
#include "Servo.h"
// Create a servo object
Servo myservo;
// Set the pin where the servo is connected
int servoPin = 4;
void setup()
{
// Attach the servo object to the pin
myservo.attach(servoPin);
}
void loop()
{
// Move the servo from 0 to 180 degrees
for (int i = 0; i < 180; i++)
{
myservo.write(i);
delay(15);
}
// Move the servo from 180 to 0 degrees
for (int i = 180; i > 0; i--)
{
myservo.write(i);
delay(15);
}
}