Powering speedystepper17 with A4988

spe_SPEEDYSTEPPER17-304_201214_1.pdf (203.0 KB)
I have wired my stepper motor to my Arduino Mega. Making sure the coils are in the correct place. The stepper sort of moves but outputs almost no torque.

A4988 Pinout:

  • VMOT → Motor Power Supply (8V to 35V)
  • GND → Ground (Power Supply and Microcontroller)
  • VDD → Logic Voltage (3.3V or 5V from Microcontroller)
  • STEP → Step signal from Microcontroller
  • DIR → Direction signal from Microcontroller
  • 1A, 1B, 2A, 2B → Stepper Motor Windings
  • ENABLE (EN) → Optional, connect to GND to enable driver

Stepper Motor Wiring:

Refer to the wiring diagram in the datasheet. The motor has 4 wires:

  • Red → Coil A+
  • Yellow → Coil A-
  • Blue → Coil B+
  • Orange → Coil B-

:white_check_mark: Connect the motor wires:

  • 1A → Red (A+)
  • 1B → Yellow (A-)
  • 2A → Blue (B+)
  • 2B → Orange (B-)

:white_check_mark: Connect power:

  • VMOT → 12V to 24V (external supply)
  • GND → Ground of the supply

:white_check_mark: Microcontroller to A4988:

  • VDD → 5V from Arduino
  • GND → Ground of Arduino
  • STEP → Any digital pin (e.g., D2)
  • DIR → Any digital pin (e.g., D3)
  • EN → GND (always enabled or use a control pin if needed)

I have done everything here and the stepper jitters sometimes, other times it moves, but like I said it has no torque and doesn't seem to be keeping up with the steps. I'm totally stumped on this.

This is the code I was using:

#define STEP_PIN 3  // Connect A4988 STEP pin to Arduino D3
#define DIR_PIN 4   // Connect A4988 DIR pin to Arduino D4
#define EN_PIN 8    // Connect A4988 ENABLE pin to Arduino D8 (optional)

const int stepsPerRevolution = 200;  // 200 steps per revolution for 1.8° stepper motor
const int microstepping = 1;         // Adjust this if you're using microstepping (1, 2, 4, 8, 16)

void setup() {
  pinMode(STEP_PIN, OUTPUT);
  pinMode(DIR_PIN, OUTPUT);
  pinMode(EN_PIN, OUTPUT);

  digitalWrite(EN_PIN, LOW);  // Enable the motor driver (LOW to enable, HIGH to disable)
  digitalWrite(DIR_PIN, HIGH);  // Set initial direction
  Serial.begin(9600);
  Serial.println("A4988 stepper motor ready...");
}

void loop() {
  Serial.println("Moving clockwise...");
  rotateMotor(stepsPerRevolution * microstepping);  // Move 1 full revolution clockwise
  delay(1000);

  Serial.println("Moving counterclockwise...");
  digitalWrite(DIR_PIN, LOW);  // Change direction
  rotateMotor(stepsPerRevolution * microstepping);  // Move 1 full revolution counterclockwise
  delay(1000);
}

// Function to pulse STEP pin to rotate motor
void rotateMotor(int steps) {
  for (int i = 0; i < steps; i++) {
    digitalWrite(STEP_PIN, HIGH);
    delayMicroseconds(800);  // Adjust delay for speed control
    digitalWrite(STEP_PIN, LOW);
    delayMicroseconds(800);
  }
}

To what current is the A4988 set?
What is the max current from the power supply?

Power supply is 2A. I turned the screw on the driver slowly while the motor was stepping and it did not seem to change anything.

@remusconnor

Add the line as above

Tie Reset and Sleep pins together

You may need to wire the motor pins as in this working Wokwi with your code

Do you think I need the capacitor?

It wouldn't hurt for sure, unless your power supply has some built in.

That didn't solve the problem but it's a not good way to trim the current within stepper limits. Too much current and the stepper gets overheated.

Try this:

void rotateMotor(int steps) {
  for (int i = 0; i < steps; i++) {
    digitalWrite(STEP_PIN, HIGH);
    delayMicroseconds(10);  // Pulse width minimum
    digitalWrite(STEP_PIN, LOW);
    delayMicroseconds(20000);// Can be trimmed down
  }

I have it wired just like in the picture. It still barely moves.

Hi, @remusconnor

Can you post some images of your project?
So we can see your component layout.

Thanks.. Tom.... :smiley: :+1: :coffee: :australia:




Hi, @remusconnor
Thanks for the pics.

Do you have a DMM? (Digital MultiMeter)

Can you verify the coil connections on the stepper if you do have a DMM?

Thanks.. Tom.... :smiley: :+1: :coffee: :australia:

I did this. I get the stepper to move, but it has like 0 torque. If I barely touch it with my hand it skips. I'm using a 19V 2.37A and still the same problem...

Hi, @remusconnor

void rotateMotor(int steps) {
  for (int i = 0; i < steps; i++) {
    digitalWrite(STEP_PIN, HIGH);
    delay(10);  // Pulse width minimum
    digitalWrite(STEP_PIN, LOW);
    delay(100);// Can be trimmed down
  }

Slow everything down.

Can you please post a copy of your circuit, a picture of a hand drawn circuit in jpg, png?
Hand drawn and photographed is perfectly acceptable.
Please include ALL hardware, power supplies, component names and pin labels
In other words, REVERSE engineer your project.

Thanks.. Tom.... :smiley: :+1: :coffee: :australia:

You may be expecting too much from your relatively small Nema17 motor. It only has a few watts of power. You seem to have quite a large mass mounted on it. I would also wonder about how much radial force is on the motor shaft, that could affect it's ability to turn.

I would suggest removing all mechanical load from the motor and test it that way.