Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Servo.h> //header for servo
- Servo myservo; //declare servo
- int angle=0; //set initial angle to 0
- void setup(){
- myservo.attach(9); //attach servo to digital pin 9
- }
- void loop(){
- for (angle=0 ; angle<180 ; angle+=6){
- myservo.write(angle); //write servo angle from 0 to 180 and back, steps up the angle of servo by 6 degrees (speed)
- delay(20); // dispense 20ms
- }
Advertisement
Add Comment
Please, Sign In to add comment