Guest User

Untitled

a guest
Apr 19th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 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.  
  16. Used in Class for Object Lab 5 Part 3
  17.  
  18. Modified by:
  19.  
  20. Aidan Rafferty
  21.  
  22. 10 Apr. 2018
  23.  
  24. */
  25.  
  26. #include <Stepper.h>
  27.  
  28. const int stepsPerRevolution = 48; // change this to fit the number of steps per revolution
  29. // for your motor
  30.  
  31. // initialize the stepper library on pins 8 through 11:
  32. Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11);
  33.  
  34. void setup() {
  35. // set the speed at 60 rpm:
  36. myStepper.setSpeed(60);
  37. // initialize the serial port:
  38. Serial.begin(9600);
  39. }
  40.  
  41. void loop() {
  42. // step one revolution in one direction:
  43. Serial.println("clockwise");
  44. myStepper.step(stepsPerRevolution);
  45. delay(500);
  46.  
  47. // step one revolution in the other direction:
  48. Serial.println("counterclockwise");
  49. myStepper.step(-stepsPerRevolution);
  50. delay(500);
  51. }
Add Comment
Please, Sign In to add comment