Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Adjusted from Sweep example by Stijn van der Lippe
- #include <Servo.h>
- Servo myservo; // create servo object to control a servo
- // twelve servo objects can be created on most boards
- int pos = 90; // variable to store the servo position, starts at 90 degrees
- void setup() {
- myservo.attach(9); // attaches the servo on pin 9 to the servo object
- }
- void loop() {
- myservo.write(pos); // tell servo to go to position in variable 'pos'
- delay(2); // waits 2ms for the servo to reach the position
- pos += 5; // set position variable forward 5 degrees
- myservo.write(pos); // tell servo to go to position in variable 'pos'
- delay(2); // waits 2ms for the servo to reach the position
- pos -= 5; // set position variable back 5 degrees
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement