Guest User

Untitled

a guest
Apr 20th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. /*
  2. Stepper Motor Control - one revolution
  3.  
  4. This program drives a unipolar or bipolar stepper motor.
  5. The motor is attached to digital pins 8 - 11 of the Arduino.
  6.  
  7. The motor should revolve one revolution in one direction, then
  8. one revolution in the other direction.
  9.  
  10.  
  11. Created 11 Mar. 2007
  12. Modified 30 Nov. 2009
  13. by Tom Igoe
  14.  
  15. Modified 10/4/18 by Juliet Luna
  16.  
  17. */
  18.  
  19. #include <Stepper.h>
  20.  
  21. const int stepsPerRevolution = 48; // change this to fit the number of steps per revolution
  22. // for your motor
  23.  
  24. // initialize the stepper library on pins 8 through 11:
  25. Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11);
  26.  
  27. void setup() {
  28. // set the speed at 60 rpm:
  29. myStepper.setSpeed(60);
  30. // initialize the serial port:
  31. Serial.begin(9600);
  32. }
  33.  
  34. void loop() {
  35. // step one revolution in one direction:
  36. Serial.println("clockwise");
  37. myStepper.step(stepsPerRevolution);
  38. delay(500);
  39.  
  40. // step one revolution in the other direction:
  41. Serial.println("counterclockwise");
  42. myStepper.step(-stepsPerRevolution);
  43. delay(500);
  44. }
Add Comment
Please, Sign In to add comment