Advertisement
Guest User

arduino stepper test for pololu break out board

a guest
Jul 16th, 2010
840
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. /*
  2. stepper test sketch for pololu stepper driver board.
  3.  
  4. connect enable pin to arduino pin 10
  5. connect step pin to arduino pin 9
  6. connect direction pin to arduino pin 8
  7.  
  8. The sketch lights led13 and runs the stepper 400 steps in one direction
  9. then it waits on second, then turns off the led13 and runs the stepper 400 steps in the other direction
  10. It waits another second then repeats the 400 one way 400 the other way.
  11. */
  12.  
  13. int ledPin = 13; // LED connected to digital pin 13
  14. int enx = 10;
  15. int stepx = 9;
  16. int dirx = 8;
  17.  
  18. // The setup() method runs once, when the sketch starts
  19.  
  20. void setup() {
  21. // initialize the digital pin as an output:
  22. pinMode(ledPin, OUTPUT);
  23. pinMode(enx, OUTPUT);
  24. pinMode(stepx, OUTPUT);
  25. pinMode(dirx, OUTPUT);
  26. digitalWrite(enx, HIGH);
  27. digitalWrite(stepx, LOW);
  28. digitalWrite(dirx, LOW);
  29.  
  30. }
  31.  
  32. // the loop() method runs over and over again,
  33. // as long as the Arduino has power
  34.  
  35. void loop()
  36. {
  37. digitalWrite(enx, LOW);
  38. digitalWrite(dirx, HIGH);
  39. digitalWrite(ledPin, HIGH); // set the LED on
  40. for (int x = 0; x<400; x++){
  41. digitalWrite(stepx, HIGH);
  42. delay(1);
  43. digitalWrite(stepx, LOW);
  44. // delay(1);
  45. }
  46.  
  47. delay(1000); // wait for a second
  48. digitalWrite(ledPin, LOW); // set the LED off
  49. digitalWrite(dirx, LOW);
  50. for (int x = 0; x<400; x++){
  51. digitalWrite(stepx, HIGH);
  52. delay(1);
  53. digitalWrite(stepx, LOW);
  54. // delay(1);
  55. }
  56. digitalWrite(enx, HIGH);
  57. delay(1000); // wait for a second
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement