Help with controlling Nema23 stepper motor

Hello, this is my first time building anything electrical. I've made a build attached to a hand sanitizer stand so it can stand vertically. Attached are the wiring diagram, build, and code. When I upload the code and press the tactile button to close the circuit to pin 11, nothing happens. I already checked to see if the motor is wired correctly. The colors match the documentation and when plugged in it cannot be manually turned and emits a constant low buzzing noise. I can't figure out what's wrong. Also, whenever I press the tactile button, pin 13's LED lights up for some reason...

// Define stepper motor connections:
#define dirPin 2
#define stepPin 3

void setup() {
  // Declare pins as output:
  pinMode(stepPin, OUTPUT);
  pinMode(dirPin, OUTPUT);
  pinMode(11, INPUT); 
}

void loop() {
  while (digitalRead(11)== HIGH)

{ digitalWrite(dirPin, HIGH);

digitalWrite(stepPin, HIGH);

delayMicroseconds(500);

digitalWrite(stepPin, LOW);

delayMicroseconds(500); }

}



The wiring diagram was drawn incorrectly. This is the updated one that matches the physical build:


the dark blue wire was supposed to be on ground

EN+ & EN- to GND?
pull out, they no needed for testing, EN is activated by default

1 Like
const byte stepPin = 3;

void setup() {
  pinMode(stepPin, OUTPUT);
}

void loop() {
  digitalWrite(stepPin, HIGH);
  delayMicroseconds(500);
  digitalWrite(stepPin, LOW);
  delayMicroseconds(500);
}

How is the stepper powered?

24V power supply. I followed the wiring colors for the stepper motor as shown in the third picture. Additionally, the top right LED of the DM542T stepper motor driver is lit up, so I don't think that is a problem.

void loop() {
  digitalWrite(stepPin, HIGH);
  delayMicroseconds(500);
  digitalWrite(stepPin, LOW);
  delayMicroseconds(500);
}

Jumping from 0 to 1000 steps per second won't work, the motor cannot accelerate that fast, it will just sit and buzz.
Try:

void loop() {
  digitalWrite(stepPin, HIGH);
  delayMicroseconds(8000);
  digitalWrite(stepPin, LOW);
  delayMicroseconds(8000);
}

What does that indicate? Did you set the DM542T's current limiter to match the motor's current rating? What is that current rating?