Guidance for a A4988 and arduio stepper

Hey guys, I’m a noob, as your about to find out.
I hooked up a stepper motor to the A4988 driver the same as the minimum connection for full step is illustrated on the page, and plugged my arduino to the direction and step pins. I attach my power supply to the motor voltages, but when I flip it on, the motor just steps.
I’m thinking there’s something wrong with my code, or the connections. Any suggestions? pololu.com/catalog/product/2128/faqs

Code: rotates 1000 steps then reverses:

[code]#define stepPin 4
#define dirPin 5

void setup() {
Serial.begin(9600);
Serial.println(“Starting stepper exerciser.”);

pinMode(stepPin, OUTPUT);
pinMode(dirPin, OUTPUT);

digitalWrite(dirPin, HIGH);
digitalWrite(stepPin, LOW);
}

void loop() {
int i, j;

for (i=1000; i>=200; i-=100) {
Serial.print("Speed: ");
Serial.println(i);

for (j=0; j<2000; j++) {
  digitalWrite(stepPin, HIGH);
  delayMicroseconds(i);
  digitalWrite(stepPin, LOW);
  delayMicroseconds(i);
}

delay(500);
digitalWrite(dirPin, !digitalRead(dirPin));

for (j=0; j<2000; j++) {
  digitalWrite(stepPin, HIGH);
  delayMicroseconds(i);
  digitalWrite(stepPin, LOW);
  delayMicroseconds(i);
}

delay(1000);
Serial.println("Switching directions."); 
digitalWrite(dirPin, !digitalRead(dirPin));

}
}[/code]

Hello.

Could you describe the behavior you are seeing in more detail? What do you mean when you say “the motor just steps”? Can you post some pictures that clearly show how you have the A4988 connected to your Arduino?

  • Grant

Grant,
The motor acts erratically, and stops when I touch the motor housing, some other connector on the ardiuno or the driver carrier, strange. The motor just steps forward, I’m assuming it full step mode and does not stop, unless I disconnect the step wire from the arduino. I connected the driver and arduino exactly the way that is shown on the product page of the a4988 driver carrier:

I’m wondering if something got cooked in the the choas. Whats the easiest way to check weather my driver is broken, or my arduino?
I’ve checked the stepper with an led to the leads, and I think they are okay.
Thanks!

It sounds like something might be connected incorrectly. Could you post actual pictures of your setup that clearly show how everything is connected? How are you powering everything? What is your current limit set to?

  • Grant