Zanuark

Arduino servo code

Nov 12th, 2019
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. #include <Servo.h>
  2.  
  3. servo myServo;
  4.  
  5. void setup(){
  6. myServo.attach(9);
  7. }
  8.  
  9. void loop(){
  10. myServo.write(180); // 180 = forward
  11. delay(1000);
  12. myServo.write(90); // 180 = stop
  13. delay(1000);
  14. myServo.write(0); // 180 = backward
  15. delay(1000);
  16. myServo.write(90); // 180 = stop
  17. delay(1000);
  18. }
  19.  
  20. // adjust the stop value as needed. I worked with a servo that had to be set to 90.
Advertisement
Add Comment
Please, Sign In to add comment