Stepper motor vibrates but not working properly

Hello, I am trying to use this tutorial I found to make a stepper motor work:

Using his code:

/*     Simple Stepper Motor Control Exaple Code
 *  by Dejan Nedelkovski,

// defines pins numbers
const int stepPin = 3; 
const int dirPin = 4; 
void setup() {
  // Sets the two pins as Outputs
void loop() {
  digitalWrite(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++) {
  delay(1000); // One second delay
  digitalWrite(dirPin,LOW); //Changes the rotations direction
  // Makes 400 pulses for making two full cycle rotation
  for(int x = 0; x < 400; x++) {

This is my first time doing anything Arduino, and I’m not too good with electronics so please bare with me. I did not go into the “current limiting” section of his tutorial. Here is a list of the components I used:

12 v adaptor:

stepper motor:


After I upload the code, the stepper motor might do nothing or it might make random whining and beeping noises depending on the position of the little screw on the driver( i think thats a potentiometer?). There is one time when I uploaded the code the motor appeared to be working. It spun 1 full rotation, paused for a second, spun again, and repeat. But it only spun in one direction, while the code makes it spin one way and then back the other. Then after I screwed the little screw on the driver, I couldnt get it to fully rotate again, just a few degrees in one direction. Please help, thank you in advance.

I have it wired up exactly how it is in the scehmatic, except with a jumper wire from sleep to reset. As for the stepper motor wires I have black to 1b, green to 1a, red to 2a, blue to 2b

try this

_11_Stepper_Motor.ino (865 Bytes)

These links may help
Stepper Motor Basics
Simple Stepper Code

A 2 amp motor is a bit too much for an A4988 - it will almost certainly overheat and shut down. Try setting the current limit at 1.5 amps and see if that helps. It should be enough to make the motor rotate but it obviously will not develop the full torque.

For a 2 amp motor I suggest you get a driver that can handle 3 amps so you have a bit of headroom. The drivers that use the TB66xx chip will probably be the cheapest - otherwise you are faced with buying a much more expensive commercial product.


I use those drivers and have spent quite some time to understand them. I have a Protooner board carrying 4 of those drivers. How are Your drivers connected to the Arduino X?

Don't randomly change the screw on those drivers! That is the setting for the current limit for the coils in the stepper. Too little, less power, too much, overheated steppers and drivers. Google and find the way to set the current limit for Your stepper. For maximum 1,5 Amps You will need a fan cooling the drivers even with a 12 volt pwr supply.
The delays, delayMicroseconds(500), might be at bit too short. Start using a few milliseconds, delay(5);