donmike25

servo final final final (canduino)

Mar 23rd, 2016
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.38 KB | None | 0 0
  1. #include <Servo.h> //header for servo
  2.  
  3. Servo myservo; //declare servo
  4.  
  5. int angle=0; //set initial angle to 0
  6.  
  7. void setup(){
  8.  
  9. myservo.attach(9); //attach servo to digital pin 9
  10. }
  11.  
  12. void loop(){
  13.  
  14. for (angle=0 ; angle<180 ; angle+=6){
  15. myservo.write(angle); //write servo angle from 0 to 180 and back, steps up the angle of servo by 6 degrees (speed)
  16. delay(20); // dispense 20ms
  17. }
Advertisement
Add Comment
Please, Sign In to add comment