Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Stepper.h>
- int pinobotao_ah = 3;
- int pinobotao_h = 2;
- int passos = 30;
- int leitura = 0;
- int leitura2 = 0;
- const int stepsPerRevolution = 200;
- Stepper myStepper(stepsPerRevolution, 8,9,10,11);
- void setup()
- {
- pinMode(pinobotao_h, INPUT);
- pinMode(pinobotao_ah, INPUT);
- myStepper.setSpeed(60);
- }
- void loop()
- {
- //Gira o motor no sentido horario
- leitura = digitalRead(pinobotao_h);
- if (leitura != 0)
- {
- myStepper.step(passos);
- }
- //Gira o motor no sentido anti-horario
- leitura2 = digitalRead(pinobotao_ah);
- if (leitura2 != 0)
- {
- myStepper.step(-passos);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement