Advertisement
Guest User

Untitled

a guest
Nov 7th, 2015
441
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. #include <Stepper.h>
  2. int pinobotao_ah = 3;
  3. int pinobotao_h = 2;
  4. int passos = 30;
  5. int leitura = 0;
  6. int leitura2 = 0;
  7. const int stepsPerRevolution = 200;
  8. Stepper myStepper(stepsPerRevolution, 8,9,10,11);
  9.  
  10. void setup()
  11. {
  12. pinMode(pinobotao_h, INPUT);
  13. pinMode(pinobotao_ah, INPUT);
  14. myStepper.setSpeed(60);
  15. }
  16.  
  17. void loop()
  18. {
  19. //Gira o motor no sentido horario
  20. leitura = digitalRead(pinobotao_h);
  21. if (leitura != 0)
  22. {
  23. myStepper.step(passos);
  24. }
  25.  
  26. //Gira o motor no sentido anti-horario
  27. leitura2 = digitalRead(pinobotao_ah);
  28. if (leitura2 != 0)
  29. {
  30. myStepper.step(-passos);
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement