Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 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.  
  17. #include <Stepper.h>
  18.  
  19. const int stepsPerRevolution = 200; // change this to fit the number of steps per revolution
  20. // for your motor
  21.  
  22. // initialize the stepper library on pins 8 through 11:
  23. Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11);
  24.  
  25. void setup() {
  26. // set the speed at 60 rpm:
  27. myStepper.setSpeed(1);
  28. // initialize the serial port:
  29. Serial.begin(9600);
  30. }
  31.  
  32. void loop() {
  33. // step one revolution in one direction:
  34. Serial.println("clockwise");
  35. myStepper.step(stepsPerRevolution);
  36. delay(500);
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement