// Servo Start (Back and Forth) w/ Arduino Servo Library // // Setup: - Connect a servo to +, gnd and digital pin 9 // ----------------------------------------------------------- #include <Servo.h> Servo myservo; // create servo object to control a servo // a maximum of eight servo objects can be created int servoPin = 9; // variable for servo pin number void setup() { myservo.attach(servoPin); // attaches the servo on pin 9 to the servo object } void loop() { myservo.write(180); // tell servo to go to position 180 delay(1500); myservo.write(0); // tell servo to go to position 0 delay(1500); } |