3

So, I have been following this tutorial on how to run a stepper motor with Arduino using an A4988 Stepper Driver. This is the tutorial: How To Control a Stepper Motor with A4988 Driver and Arduino. I have connected the wires according to this schematic:

Schematic

I have connected the wires exactly like this and triple-checked it! The problem is the stepper motor is not turning. This is the code(it's simple):

// defines pins numbers
const int stepPin = 3; 
const int dirPin = 4; 

void setup() {
  // Sets the two pins as Outputs
  pinMode(stepPin,OUTPUT); 
  pinMode(dirPin,OUTPUT);
}

void loop() {
  digitalWrithe(dirPin,HIGH); // Enables the motor to move in a particular direction
  // Makes 200 pulses for making one full cycle rotation
  for(int x = 0; x < 200; x++) {
    digitalWrite(stepPin,HIGH); 
    delayMicroseconds(500); 
    digitalWrite(stepPin,LOW); 
    delayMicroseconds(500); 
  }
  delay(500); // One second delay
}

One weird thing:

When I connect the sleep and reset pin on the A4988 board the stepper motor starts turning. Like why?

NOTE: I replaced the MEGA with a UNO because at the moment I'm just testing.

Gaurav Mall
  • 134
  • 1
  • 8

1 Answers1

4

You have to connect the sleep and reset pin together. I assume that you took this schema on how to mechatronics. In his video you see that the sleep and reset pins are connected. I don't know why but it has to be like that.

Then, if the motor vibrates or click, it may be one of these problems:

  • You didn't connect the motor properly
  • The current is set too low on the board (screw on the motor driver)
  • The battery (Vmot) isn't powerful enough

If it's not one of those problems, the A4988 chip might have an issue. I have a similar problem where it turn in one direction and only when the pwm signal goes throught the direction pin instead of the step pin.

user
  • 56
  • 2