Note that I put the code in code tags to make it easier to copy to an editor and to avoid the forum software misinterpreting certain commands as HTML tags
#include "Servo.h" //make the Servo functions available to the program
Servo myservo; //create a Servo object named servo
int pos = 0; //declare the variable pos and set its value to 0
void setup()
{
myservo.attach(9); //tell the program to control the servo object using pin 9
}
void loop()
{
for (pos = 10; pos < 150; pos += 1) //make the value of pos vary from 10 to 149 in steps of 1
{
myservo.write(pos); //move the servo to the angle held in the pos variable
delay(15); //do nothing for 15 milliseconds
}
for (pos = 150; pos >= 10; pos -= 1) //as above but in reverse direction 150 to 10
{
myservo.write(pos);
delay(15);
}
} //go back and do it all over again