Stepper Motor issues

Hi, sorry if this is the wrong place, as the motor I'm trying to learn to run is only 400mA, NEMA 17
I wish to control this to run very slowly via A4988 driver, which I am measuring 1V from the trimpot.

I have had the thing running, but blown a lot of drivers, due to sloppy breadboard/jumper interface, I 3D printed some headers which now lock the wires for the driver firmly in place on the breadboard. The current driver installed (my second to last one, until delivery) is delivering somekind of signal to the motor, but the motor just flutters back and forth very weakly.

my wiring is pretty much like the image attached, although I am using UNO board with jumpers between Vin/gnd and 12V rail on breadboard and here is my code (I commented out the button references, but I wish to add at least one limit switch, maybe two, for homing and perhaps a return, altho I would prefer to rotate a given number of revs and the return to home and start again, at very low speed...

#include <Stepper.h>
int stepsPerRevolution = 200;
int motSpeed = 100;
int dt = 500;

int motorDir = 1;
; int buttonPin = 8;
; int buttonValNew;
; int buttonValOld = 1;

Stepper myStepper(stepsPerRevolution, 2, 3, 5, 6);

// Declare pin functions on RedBoard
#define stp 2;
#define dir 3;
#define MS1 4;
#define MS2 5;
#define EN 6;

void setup() {
// put your setup code here to run once
Serial.begin (9600);
; pinMode(buttonPin, INPUT);
; digitalWrite(buttonPin, HIGH);


void loop () {

; buttonValNew = digitalRead(buttonPin);
; if (buttonValOld == 1 && buttonValNew == 0);
; motorDir = motorDir * (-1);

// myStepper.step(stepsPerRevolution);
// delay(dt);
// myStepper.step(-stepsPerRevolution);
// delay(dt);
// }

Any guidance would be very much appreciated if possible.


This is wrong for an A4988

Stepper myStepper(stepsPerRevolution, 2, 3, 5, 6);

an A4988 just takes step and direction signals so you should use (I hope I have the order correct, but if its wrong it will be obvious)

Stepper myStepper(stepsPerRevolution, stepPin, DirectionPin);

Even better, use the AccelStepper library.

Or just try writing your own code without any library as illustrated in this Simple Stepper Code

Whatever approach you choose make sure to start with a very slow speed.

Stepper Motor Basics

Hi, yes, I've moved on from that, and thankfully, now it's not silly oclock in the morning, I don't have Vin connected to 12v! I think that code you pointed out may have been for easydriver I was messing with when I began dabbling before an extended break...

I'm about to test a new code, fingers crossed and many thanks

The ground connection from the Arduino circuit to the A4988 module should go direct from the Arduino,
right alongside the step and direction wires. Every signal wire needs a return path for the current that's
alongside its wire, otherwise you'll risk picking up interference.

You've also omitted the ground connection from the 5V power connector to the Arduino itself.

Definitely go for the AccelStepper library, you need speed ramping for a stepper unless its
microscopic in size (or you only want it to step slowly).