/* "Broom" Servo This example demonstrates the servo drive movement with a smooth stop in both directions */ #include Servo servo; // create an Servo class instance to control the servo int pos = 0; // variable for storing servo position void setup() { servo.attach(8); // connecting the servo drive to digital pin 8 (D8) } void loop() { for (pos = 0; pos <= 180; pos += 1) { // change degrees from 0 to 180 servo.write(pos); // command to servo drive - go to position of variable "pos" delay(15); // waiting for the servo to get there } for (pos = 180; pos >= 0; pos -= 1) { // change degrees from 180 to 0 servo.write(pos); // command to servo drive - go to position of variable "pos" delay(15); // waiting for the servo to get there } }