Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- stepper test sketch for pololu stepper driver board.
- connect enable pin to arduino pin 10
- connect step pin to arduino pin 9
- connect direction pin to arduino pin 8
- The sketch lights led13 and runs the stepper 400 steps in one direction
- then it waits on second, then turns off the led13 and runs the stepper 400 steps in the other direction
- It waits another second then repeats the 400 one way 400 the other way.
- */
- int ledPin = 13; // LED connected to digital pin 13
- int enx = 10;
- int stepx = 9;
- int dirx = 8;
- // The setup() method runs once, when the sketch starts
- void setup() {
- // initialize the digital pin as an output:
- pinMode(ledPin, OUTPUT);
- pinMode(enx, OUTPUT);
- pinMode(stepx, OUTPUT);
- pinMode(dirx, OUTPUT);
- digitalWrite(enx, HIGH);
- digitalWrite(stepx, LOW);
- digitalWrite(dirx, LOW);
- }
- // the loop() method runs over and over again,
- // as long as the Arduino has power
- void loop()
- {
- digitalWrite(enx, LOW);
- digitalWrite(dirx, HIGH);
- digitalWrite(ledPin, HIGH); // set the LED on
- for (int x = 0; x<400; x++){
- digitalWrite(stepx, HIGH);
- delay(1);
- digitalWrite(stepx, LOW);
- // delay(1);
- }
- delay(1000); // wait for a second
- digitalWrite(ledPin, LOW); // set the LED off
- digitalWrite(dirx, LOW);
- for (int x = 0; x<400; x++){
- digitalWrite(stepx, HIGH);
- delay(1);
- digitalWrite(stepx, LOW);
- // delay(1);
- }
- digitalWrite(enx, HIGH);
- delay(1000); // wait for a second
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement