this is my second Arduino project and I am trying to figure out why my stepper motor is not moving. I was able to get a basic 28byj-48 stepper motor to work using stepper.h and some sample code.
Now I am trying a new setup and not getting any turning action. I do see power to the Arduino stepper motor and power supply and can hear the motor buzzing its just not turning when uploading the Arduino code:
#define STEP_PIN 9
#define DIR_PIN 8
void setup() {
pinMode(STEP_PIN, OUTPUT);
pinMode(DIR_PIN, OUTPUT);
digitalWrite(DIR_PIN, HIGH); // or LOW to change direction
}
void loop() {
for (int i = 0; i < 8000; i++) {
digitalWrite(STEP_PIN, HIGH);
delayMicroseconds(100);
digitalWrite(STEP_PIN, LOW);
delayMicroseconds(100);
}
}
Setup :
Power : 24V 10A 240W AC/DC Power Adapter
Motor : STEPPERONLINE Nema 17 Stepper Motor Bipolar 2A
Stepper Driver: STEPPERONLINE CNC Stepper Motor Driver 1.0-4.2A 20-50VDC 1/128 Micro-Step Resolutions for Nema 17 and 23 Stepper Motor
Pin Config :
Stepper Motor
Driver Terminal | Wire Color from Motor |
---|---|
A+ | Black |
A− | Green |
B+ | Red |
B− | Blue |
Power Supply is wired to +vdc and GRND
Arduino is wired
- pin 8 to DIR +
- pin 9 to PUL +
For DIR - and PUL - Both are plugged into this breadboard and there is a pin from there into the Arduinos GRND.
Where should I look next for potential issues on why the motor isn't rotating ?
-
Would you mind to edit your question to add the working minimal sample code, please?the busybee– the busybee2025年05月21日 07:48:15 +00:00Commented May 21 at 7:48
-
1As there is no standard on what colors the motor wires should have, try swapping them around a bit and see, if that changes something.chrisl– chrisl2025年05月21日 13:21:41 +00:00Commented May 21 at 13:21
-
you should find with a multimeter what wires on the motor are connected to same coil (one coil should go to A, another to B). Second, check switches on the driver that they have correct microstepping and current. Try reducing microstepping and increasing current. Third, the driver seems to also have ENA pins, maybe you need to wire them to power or ground also (look into datasheet).Osman-pasha– Osman-pasha2025年05月22日 13:51:36 +00:00Commented May 22 at 13:51
1 Answer 1
If your stepper motor is just buzzing but not rotating, you can checkout following things:
Wiring – Double-check motor coil connections (A+/A− and B+/B−). Incorrect coil pairing will prevent rotation.
Step pulse timing – Try increasing delayMicroseconds(100) to 500 or more. Some drivers need slower step pulses to respond.
Enable pin – Some drivers require an EN (Enable) pin to be set LOW to activate the motor. Make sure it's either grounded or properly configured.
Power supply – You're using a 24V supply, which is good, but ensure your driver current setting matches the motor’s rated 2A.
Driver overheating/protection – Check if the driver is entering thermal or overcurrent protection.
If you want to know how to control 28BYJ-48 Stepper Motor checkout my article: 👉 How to Control 28BYJ-48 Stepper Motor with ULN2003 Driver and Arduino
Hope this helps!