// testing a stepper motor with a Pololu A4988 driver board or equivalent
// on an Uno the onboard led will flash with each step
// this version uses delay() to manage timing
byte directionPin = 8;
byte stepPin = 9;
int numberOfSteps = 100;
byte ledPin = 13;
int pulseWidthMicros = 20; // microseconds
int millisbetweenSteps = 250; // milliseconds - or try 1000 for slower steps
void setup() {
Serial.begin(9600);
Serial.println("Starting StepperTest");
digitalWrite(ledPin, LOW);
delay(2000);
pinMode(directionPin, OUTPUT);
pinMode(stepPin, OUTPUT);
pinMode(ledPin, OUTPUT);
digitalWrite(directionPin, HIGH);
for(int n = 0; n < numberOfSteps; n++) {
digitalWrite(stepPin, HIGH);
delayMicroseconds(pulseWidthMicros); // this line is probably unnecessary
digitalWrite(stepPin, LOW);
delay(millisbetweenSteps);
digitalWrite(ledPin, !digitalRead(ledPin));
}
delay(3000);
digitalWrite(directionPin, LOW);
for(int n = 0; n < numberOfSteps; n++) {
digitalWrite(stepPin, HIGH);
// delayMicroseconds(pulseWidthMicros); // probably not needed
digitalWrite(stepPin, LOW);
delay(millisbetweenSteps);
digitalWrite(ledPin, !digitalRead(ledPin));
}
}
void loop() {
}
Did you adjust the motor current?
Try to give your motor a bit more current; set the limit to 1.5A; that should be ok for both, the driver and the motor.
How about the setting of "Enable"?
ENABLE: Logic Input. Enables the FET functionality within the motor driver. If set to HIGH, the FETs will be disabled, and the IC will not drive the motor. If set to LOW, all FETs will be enabled, allowing motor control.
This is a quote from the SparkFun description; if you leave "Enable" open/unconnected the driver is not set to a stable configuration and the input to Enable may float, causing it to erratic enabling/disabling the motor output.
So: set Enable to LOW (you can hardwire this if you want to test your configuration); later you can control Enable by only setting it to LOW, when you want to turn the motor.
What about microstepping?
By default (= nothing connected to MS1..MS3) your driver is set to 1/16
To give it a start, begin with setting MS1..MS3 all to LOW = Full step.
When your tests are successful, you can then play with the microstepping parameters.
See detailled information about the BigEasy Driver here.
its a EasyDriver on the schematic, but i assume its the same connections on a Big EasyDriver.
Never assume - always always check the datasheet and provided documentation before connecting
and powering up anything - its can be a very expensive mistake if you don't check and double-check.
And please show us exactly how you have connected it - a diagram featuring the wrong board isn't
useful.