Rywo

exercise 8

Jun 18th, 2019
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. #include <Servo.h>
  2. Servo myServo; // Declare a servo object for us to control
  3. int servoPin = 9; // Var for the pin the servo connects to
  4. int pos = 0; // Var to keep track of the servo's position
  5.  
  6. void setup() {
  7. myServo.attach(servoPin); //Tell the servo to what pin it's connected to
  8. }
  9.  
  10. void loop() {
  11. for(pos = 0; pos < 50; pos += 1){
  12. myServo.write(pos);
  13. delay(15);
  14. }
  15. for(pos = 50; pos < 100; pos += 5){
  16. myServo.write(pos);
  17. delay(15);
  18. }
  19. for(pos = 200; pos < 160; pos += 1){
  20. myServo.write(pos);
  21. delay(15);
  22. }
  23. for(pos =360; pos>=1; pos -= 20){
  24. myServo.write(pos);
  25. delay(15);
  26. }
  27. }
Add Comment
Please, Sign In to add comment