Stepper motor failing

Hi! I have a stepper motor (driver pololu 4988) controlled with Arduino, it sends signals to a scene in Unity. The motor must to rotate (clockwise or counterclockwise) a light polystyrene base. I'm having problems becase sometimes it doesn't rotate with enough strong (very very slowly) or it rotates in only one direction. I attach the Arduino code.

    #include <SerialCommand.h>
    #include <SoftwareSerial.h>
    #define DEBUG(a) Serial.println(a);
    const int dirPin = 2;
    const int stepPin = 3;
    float right = 0;
    float left = 0;
    const int steps = 200;
    int stepDelay;
    
    
    void setup() {
      // Mark pins as OUT
      pinMode(dirPin, OUTPUT);
      pinMode(stepPin, OUTPUT);
      Serial.begin(9600);
    }
    
    void loop() {
      if (Serial.available()) {
        int data = Serial.parseInt();
        Serial.print(data);
        DEBUG(data);
        if (data > 1 ) {
          right = data;
          //Change direction and increase speed
          digitalWrite(dirPin, HIGH);
          stepDelay = 600;
          //Turn 400 steps to complete 2 turns
          for (int x = 0; x < right; x++) {
            digitalWrite(stepPin, HIGH);
            delayMicroseconds(stepDelay);
            digitalWrite(stepPin, LOW);
            delayMicroseconds(stepDelay);
          }
        }
    
        if (data < 0) {
          left = data;
          left *=-1;
          digitalWrite(dirPin, LOW);
          stepDelay = 600;
          // Turn 200 steps to complete 2 turns
          for (int x = 0; x < left; x++) {
            digitalWrite(stepPin, HIGH);
            delayMicroseconds(stepDelay);
            digitalWrite(stepPin, LOW);
            delayMicroseconds(stepDelay);
          }
        }
      }}
    
      /*//Activate a dirección and lock a speed with stepDelay
        digitalWrite(dirPin, HIGH);
        stepDelay = 600;
        // Turn 200 steps to complete 2 turns
        for (int x = 0; x < left; x++) {
         digitalWrite(stepPin, HIGH);
         delayMicroseconds(stepDelay);
         digitalWrite(stepPin, LOW);
         delayMicroseconds(stepDelay);
        }
        delay(1000);
    
        //Change direction and increase speed
        digitalWrite(dirPin, LOW);
        stepDelay = 600;
        // Turn 400 steps to complete 2 turns
        for (int x = 0; x < right; x++) {
         digitalWrite(stepPin, HIGH);
         delayMicroseconds(stepDelay);
         digitalWrite(stepPin, LOW);
         delayMicroseconds(stepDelay);
        }
        delay(1000);
      */

Thanks!

Please post links to the stepper motor, the stepper motor power supply and a clear wiring diagram (not Fritzing).

To what value did you set the current limit on the A4988 driver (a required step)?

The stepper may not be able to go from 0 right to 833 steps per second without acceleration. Does it work better at lower speeds.

This Pololu A4988 page shows how to adjust the current limit.

These links may help

Stepper Motor Basics
Simple Stepper Code

...R