Advertisement
Guest User

vg

a guest
Nov 20th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. #include <Stepper.h>
  2. // Define number of steps per rotation:
  3. const int stepsPerRevolution = 2048;
  4. // Wiring:
  5. // Pin 8 to IN1 on the ULN2003 driver
  6. // Pin 9 to IN2 on the ULN2003 driver
  7. // Pin 10 to IN3 on the ULN2003 driver
  8. // Pin 11 to IN4 on the ULN2003 driver
  9. // Create stepper object called 'myStepper', note the pin order:
  10. Stepper myStepper = Stepper(stepsPerRevolution, 8, 10, 9, 11);
  11. void setup() {
  12. // Set the speed to 5 rpm:
  13. myStepper.setSpeed(5);
  14.  
  15. // Begin Serial communication at a baud rate of 9600:
  16. Serial.begin(9600);
  17. }
  18. void loop() {
  19. // Step one revolution in one direction:
  20. Serial.println("clockwise");
  21. myStepper.step(stepsPerRevolution);
  22. delay(500);
  23.  
  24. // Step one revolution in the other direction:
  25. Serial.println("counterclockwise");
  26. myStepper.step(-stepsPerRevolution);
  27. delay(500);
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement