Starting on steppers

Hi there,

lets start with the General Guidance on how to post...

version of the IDE you are using and the board version - 1.8.12, VID: 1A86 & PID: 7523 (hope this is the correct information, have to use "arduino nano" and "ATmega328P (Old Bootloader)"


int stp = 3;  //connect pin 13 to step
int dir = 2;  // connect pin 12 to dir

int Speed = 400; //lower this number to find your best starting speed

int MaxSpeed = 100; //Lower this number to find your max speed

int accel = 1; //change this number to experiment different acceleration

//with 17HS4401 500=Speed and 100=MaxSpeed was my best result

void setup()
  pinMode(stp, OUTPUT);
  pinMode(dir, OUTPUT);

void loop()

  if (Speed == MaxSpeed)
    digitalWrite(dir, LOW);
    digitalWrite(stp, HIGH);
    digitalWrite(stp, LOW);

  if (Speed > MaxSpeed)
    digitalWrite(dir, LOW);
    Speed = Speed - accel;
    digitalWrite(stp, HIGH);
    digitalWrite(stp, LOW);

  else {


Add working links to any specific hardware as needed:

Easy Driver

A4988 Driver

Stepper #1

Stepper #2


Remember that the people trying to help cannot see your problem so give as much "ACCURATE" information as you can

So. Pretty basic, I try to get a stepper turning.
I managed to achive that with the help of Tutorial Easy Driver and Stepper #1.

Since then, a bit of testing happened and I bought stepper #2 and a A4988 driver - wanted to experiment a bit on the torque side of life.

I smoked a few arduinos due to incompentence and I am fairly sure I smoked the Easy Driver - I cannot reaccomplish the basic tutorial. You can feel either stepper working, but the "hits" or "strokes" you feel do not result in any turning. So... Screw it. Burned it. Want to use the A4988 anyways.

So here is where the actual problem comes into play.

I crosscheck everything I do with both steppers, surprisingly the results are different - no one could have guessed that. Nevertheless, it adds to meh startlement.

I went so far to use the accelstepper-lib to make things run smoothly - check at the beginning of the post for the source - just another tutorial.

With the sketch stated above here are meh results:
Stepper #2 starts to turn (lots of mechanical noise, scratching, buldging), will stall a bit into it, meaning it does a few steps forward, a few backward, a few forward, lots of noise, I THINK this looks like miswiring the coils - which it isnt. It will then continue at some point to turn again, looks nice, feels nice, no noise, no scratching, nothing. Just nice as.
Then at the MaximumSpeed, if it feels right, it stops. No noise, just a bit of feeping, simply a stop. If you give it a push with a hand it will go to fullspeed - again, nice as. If you then apply ANY KIND OF RESISTANCE - really guys, just a very descent touch with my hand - less force used than by typing on your phone - it stops. Feeping. Give it a push - runs again nice. But it is not going to start again by itself.

How do I know I connected em coils correctly? I shorted coils, tried to turn the driver, great resistance means I shorted one coil.

In comparison to every other schematic I see though my coils with the steppers are at pins 1 + 4 , 3 + 6. All schematics I see go for 1 + 3, 4 + 6. I tried that aswell, well I tried connecting anything to anything pretty much, but with 1 + 4, 3 + 6 at least something happens inside the stepper. This is the reason I am confident the wiring to the stepper is accurate.

Stepper #1 will just not turn at all and stall hard at any speed. If you cannot grasp my superb description I will upload a video - just let me know. I do not know if this problem is common and I keep being too foolish to see my obvious mistake.

My goal is to have a stepper turning with a reasonable torque. At the end of the day I would like to use 2 gear shafts on it and rotate something. Since I utilize a 3D-Printer for printing different gear shafts, it is a pleasant way for my little project. Might not be the best engineering here, but that doesnt really matter to the topic on why the steppers aint turning.

Did I damage the steppers? Do now know for sure, I opened them and they look fine to me.

External power source (applied to the upper breadboard - wanted to easily differ between 5V and external source) is 12V & 1Amp. Of course, I used the steppers with different power sources, so at some point they were able to access up to 24V and 4Amp - not at the same time though.

I played around with the potentiometers on the drivers - even went into calculation as stated in the tutorial, but ... same same.

Let me know if my post lacks any information you would like to have. Looking forward to testing around with your input. :slight_smile:

Thanks a lot in advance!


I suggest you start testing with this Simple Stepper Code. Don't go chasing all sorts of different programs to find a solution. Also start with a very slow step rate - perhaps 2 or 5 steps per second.

And make sure the current limit on the stepper driver is set correctly for the motor.

If you need more help please post links to the datasheets for your stepper motors.

Stepper Motor Basics

Hi Robin,

thank you for your reply.
I had a very specific look on your posts earlier, nevertheless - I read them again.

What I was able to determine using the simple stepper code is that with every 4th step the stepper goes backwards.

That made me assume I burned another driver - correctly, cause a new one fixed that.

So I went back to this code:

// Include the AccelStepper Library
#include <AccelStepper.h>

// Define pin connections
const int dirPin = 2;
const int stepPin = 3;

// Define motor interface type
#define motorInterfaceType 1

// Creates an instance
AccelStepper myStepper(motorInterfaceType, stepPin, dirPin);

void setup() {
  // set the maximum speed, acceleration factor,
  // initial speed and the target position

void loop() {
  // Change direction once the motor reaches target position
  if (myStepper.distanceToGo() == 0) 

  // Move the motor one step;

During acceleration the stepper goes into the buzzing mode, eventhough the new driver is being utilized.

That got me going.

I played around with millisbetweenSteps and figured:
1 - 4 everything works nicely.
5 - it sounds problematic, no issues to see though
6 - 7 it buzzes around. Everytime i reset the arduino it buzzes a little bit different, nevertheless - it buzzes
8 - 9 it sounds again a bit problematic, works fine though.

1000: steps are being done correctly, correct direction, every step looks and sounds the same.

This result can be reproduced with both steppers - so i’d guess it aint the stepper.

Datasheet Stepper #1
Datasheet Stepper #2

This problem results in me being unable to use the stepper at moderate speeds WITH acceleration / deceleration.

Any more hints on what I am doing wrong?

Thanks!! :slight_smile:


An unloaded stepper is completely undamped and will resonate and miss-step very easily indeed
at its resonant frequency (*)

However if you use a reasonable amount of micro-stepping, such as x16, resonance is greatly reduced.

If you damp the stepper rotor (driving a sprocket/belt system usually results in good damping), it will
be much less susceptible to resonance anyway, but microstepping is the main defence against noise,
vibration, and resonance.

(*) Resonant frequency depends on the moment of inertia of the rotor and its load, so simply attaching
something to the motor will change the frequency. You can often hear the resonance if you issue full-steps
every second or so. Adding a cardboard pointer to the shaft can make the movement visible too.

So I went back to this code:

I thought I specifically said not to go chasing other programs for a solution. My simple code works. Stick with it until you have things working normally.

What I was able to determine using the simple stepper code is that with every 4th step the stepper goes backwards.

That is not what the first of my programs does. It moves 100 steps in one direction then 100 steps in the other direction.

And if you are using a very slow step rate you won’t have any problems with resonance.


Yes Robin, you did.

But since your code is - to me - a "debugging" thing and I expected to have fixed any issues due to positively identifying a faulty driver.

So I tried to proceed with "a project" and went for sth. more sophisticated. I am not entirely new to programming, so I not only played around with your values, I did so with the accelstepperlib aswell. Using the other code made me realise there are more troubles - which is why I went back to your code to analyse some more.

I am sorry if this behaviour hit a nerve with you. I was trying to pinpoint any issues some more, so I dont have to ask every little detail here.

Yes, your simple code works. Until i hit 5 - 8 millis inbetween steps.

I am aware that your program does not go backward every 4th step - but my stepper did. Hence I realized that the problem must be somewhere else - the driver. Which I exchanged. Thanks to your code. After having done so, I simply went forward. Once again, sorry if this behaviour hit you.
There are few else things to do I can think of that I could have done else.

Attaching a TX8 Screw with a fixed clutch and putting some work on it did not change the output (with your code).
I would be surprised if the zigzagging of my stepper is due to resonance. In my humble opinion, this is way more than resonance.

Nevertheless - you guys gave me a clue. So I will dig into that and will come back to talk about results.

Once again, Robin, sorry. I am grateful for your reply, that helped me. I am highly interested on how you would have proceeded - so I can learn some more debugging skills.


I am aware that your program does not go backward every 4th step - but my stepper did. Hence I realized that the problem must be somewhere else - the driver. Which I exchanged. Thanks to your code. After having done so, I simply went forward.

That's fine but it was not clear to me from your Reply #2