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, www.HowToMechatronics.com
 *  
 */

// 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() {
  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++) {
    digitalWrite(stepPin,HIGH); 
    delayMicroseconds(500); 
    digitalWrite(stepPin,LOW); 
    delayMicroseconds(500); 
  }
  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++) {
    digitalWrite(stepPin,HIGH);
    delayMicroseconds(500);
    digitalWrite(stepPin,LOW);
    delayMicroseconds(500);
  }
  delay(1000);
}

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: https://www.amazon.com/gp/product/B01GD4ZQRS/ref=oh_aui_detailpage_o01_s00?ie=UTF8&psc=1

stepper motor: https://www.amazon.com/gp/product/B00PNEQI7W/ref=oh_aui_detailpage_o03_s00?ie=UTF8&psc=1

driver: https://www.amazon.com/gp/product/B01FFGAKK8/ref=oh_aui_detailpage_o03_s00?ie=UTF8&psc=1

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.

...R

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);