DM542T to arduino leonardo

So I want to connect a DM542T to Arduino Leonardo and use a Potentiometer to control speed and a joystick to control direction. My pin connections are:

Potentiometer A0
Joystick A1
DM542T (Pul+) D5
DM542T (Dir+) D6
Motor (blue) B-
Motor (red) B+
Motor (green) A-
Motor (black) A+

My code is:

#define Pulse 5   // Pulse pin
#define Dir 6     // Direction pin

#define PotPin A0 // Potentiometer pin
#define JoyPin A1 // Joystick X-axis pin

int stepsPerTurn = 200;  // Number of steps per revolution
long previousMicros = 0; // Variable to store the last time pulse was sent

void setup() {
  pinMode(Pulse, OUTPUT);
  pinMode(Dir, OUTPUT);
  Serial.begin(9600); // For debugging
}

void loop() {
  int potValue = analogRead(PotPin); // Read the potentiometer value
  int joyValue = analogRead(JoyPin); // Read the joystick X-axis value

  // Map the potentiometer value to a delay value in microseconds
  long delayMicros = map(potValue, 0, 1023, 1000, 10000);

  // Determine the direction based on joystick value
  if (joyValue < 512) {
    digitalWrite(Dir, LOW); // Set direction to LOW
  } else {
    digitalWrite(Dir, HIGH); // Set direction to HIGH
  }

  // Generate pulses to drive the stepper motor
  unsigned long currentMicros = micros();
  if (currentMicros - previousMicros >= delayMicros) {
    previousMicros = currentMicros;

    // Generate pulse
    digitalWrite(Pulse, HIGH);
    delayMicroseconds(10); // Pulse width
    digitalWrite(Pulse, LOW);
  }

  // Debugging: Print values to the Serial Monitor
  Serial.print("PotValue: ");
  Serial.print(potValue);
  Serial.print("  JoyValue: ");
  Serial.print(joyValue);
  Serial.print("  delayMicros: ");
  Serial.println(delayMicros);
}

However, nothing is working. I'm using a S-400-36 to power the DM452T and Nema 23. The motor is locked and I cannot turn it physically, but I can turn it manually when it's not powered. Any help would be greatly appreciated

Are the Pul- and Dir- pins connected to Leo's GND pin?

yes

What joyValue and what potValue is shown in serial monitor?

Which version of the DM542T do you have?. The inputs of the actual version 4.0 can be switched between 24V and 5V input voltage. Factory default setting is 24V. If you don't change to 5V it will not work with the outputs of a Leonardo.