#include ; Servo myservo; // create servo object to control a servo int pos = 0; // variable to store the servo position void setup() { myservo.setPeriodHertz(50); // standard 50 hz servo myservo.attach(20, 500, 2400); // attaches the servo on GPI20 to the servo object // and sets min and max microseconds // change these values to match your servo's specifications } void loop() { // Sweep the servo from 0 to 180 degrees for (pos = 0; pos <= 180; pos += 1) { myservo.write(pos); // tell servo to go to position in variable 'pos' delay(15); // waits 15ms for the servo to reach the position } // Sweep the servo from 180 back to 0 degrees for (pos = 180; pos >= 0; pos -= 1) { myservo.write(pos); // tell servo to go to position in variable 'pos' delay(15); // waits 15ms for the servo to reach the position } }