Advertisement
Papermind

stepper

Apr 24th, 2018
1,339
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.63 KB | None | 0 0
  1. #include <Stepper.h>
  2.  
  3. const int stepsPerRevolution = 200; // change this to fit the number of steps per revolution for your motor
  4. // initialize the stepper library on pins 8 through 11:
  5. Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11);
  6.  
  7. void setup() {
  8. // set the speed at 60 rpm:
  9. myStepper.setSpeed(60);
  10. // initialize the serial port:
  11. Serial.begin(9600);
  12. }
  13.  
  14. void loop() {
  15. // step one revolution in one direction:
  16. Serial.println("clockwise");
  17. myStepper.step(stepsPerRevolution);
  18. delay(500);
  19.  
  20. // step one revolution in the other direction:
  21. Serial.println("counterclockwise");
  22. myStepper.step(-stepsPerRevolution);
  23. delay(500);
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement