Nema 17 stepper motor shakes - does not work

The motor is connected via A4988. The voltage is set to 0.5V. The engine is: 17HS4401. I tried all combinations of cable connections. The engine shakes. The power supply for A4988 is 12V and 5A. What else can I do? Other engines respond the same. Im using ESP8266 with Wi-Fi.

// Pin Definitions
#define DIR_PIN D0
#define STEP_PIN D1

void setup() {
  // Set pins as outputs
  pinMode(DIR_PIN, OUTPUT);
  pinMode(STEP_PIN, OUTPUT);
}

void loop() {
  // Set direction of movement
  digitalWrite(DIR_PIN, HIGH); // Set movement direction in one direction

  // Perform steps
  for (int i = 0; i < 200; i++) { // 200 steps for full rotation (adjust as needed)
    digitalWrite(STEP_PIN, HIGH); // Send step pulse
    delayMicroseconds(500); // Wait for the motor to complete the step
    digitalWrite(STEP_PIN, LOW); // End step pulse
    delayMicroseconds(500); // Wait before sending the next pulse (adjust speed as needed)
  }

  delay(1000); // Wait for 1 second before changing direction

  // Change direction of movement
  digitalWrite(DIR_PIN, LOW); // Change movement direction in the other direction

  // Perform steps
  for (int i = 0; i < 200; i++) { // 200 steps for full rotation (adjust as needed)
    digitalWrite(STEP_PIN, HIGH); // Send step pulse
    delayMicroseconds(500); // Wait for the motor to complete the step
    digitalWrite(STEP_PIN, LOW); // End step pulse
    delayMicroseconds(500); // Wait before sending the next pulse (adjust speed as needed)
  }

  delay(1000); // Wait for 1 second before next loop iteration
}

You MUST accelerate the stepper in order to even get close the speed you are trying to achieve.

I change the code with library, still the same problem:

#include <Stepper.h>

// Pin Definitions
#define DIR_PIN D0
#define STEP_PIN D1

// Stepper motor settings
const int stepsPerRevolution = 200; // Number of steps per full revolution
Stepper myStepper(stepsPerRevolution, DIR_PIN, STEP_PIN);

void setup() {
  // Set the speed of the stepper motor
  myStepper.setSpeed(100); // Speed in steps per second (adjust as needed)
}

void loop() {
  // Rotate in one direction
  myStepper.step(stepsPerRevolution);
  delay(1000); // Wait for 1 second before changing direction

  // Rotate in the other direction
  myStepper.step(-stepsPerRevolution);
  delay(1000); // Wait for 1 second before next loop iteration
}

I need an annotated schematic showing how you have wired this. Be sure to include all connections, power, ground, power sources etc.

Error was in ground connection... I need to add wire from ground to ESP8266, and its working fine!