#include <Servo.h>
Servo servo;
//unsigned int angle = 10;
//int angle1 = 10;
void setup() {
delay(2500); ///////// DELAY #1 this is a delay of 2.5 seconds BEFORE the servo begins
servo.attach(6);
servo.write(0);
delay(500);
// ROTATE SERVO ONCE "FAST" from 0 to 180 degrees
for (int angle2 = 0; angle2 < 180; angle2++)
{
servo.write(angle2);
delay(10); ////////// DELAY #2
}
delay(1000);
//Wait about 1 second then ROTATE SERVO ONCE SLOWLY from 180 back to 0 degrees...Want it to end up in its ORIGINAL 0 degree position
for (int angle3 = 180; angle3 > 0; angle3--)
{
servo.write(angle3);
delay(100); //////// DELAY #3
}
}
void loop() {
// Tried to write the sketch using the "void Loop" but was unsuccessful in having the servo cycle JUST ONCE
// (...tried using While, Break, Exit ....and I couldn't get it to work.
// So just using the "void setup" I was able to get the servo to cycle just ONCE.
}