#include <Servo.h>
//- servos move half a circle 0-180 degrees.
Servo baseMotor;
//- runs only once when you turn on
void setup() {
baseMotor.attach(6);
}
//- runs forever in a loop after setup
void loop() {
int counter = 0;
int angle = 0;
//- move from 0 to 180
while (angle <= 180) {
//-do this code
baseMotor.write(angle);
delay(1000);
angle = angle + 6;
}
//- move from 180 to 0
angle = 180;
while (angle >= 0) {
baseMotor.write(angle);
delay(1000);
angle = angle - 6;
}
while (1==1) {
//-do nothing
}
}