Stepper motor problem.

Hello i have a problem. I just programmed this program, but the motors don't working.. They are not responds.

#define EN 8

//Direction pin
#define X_DIR 5
#define Y_DIR 6
#define Z_DIR 7

//Step pin
#define X_STP 2
#define Y_STP 3
#define Z_STP 4

int steps = 50; // Passi da effettuare

void setup() {
// Impostazione di pin
pinMode(X_DIR, OUTPUT); pinMode(X_STP, OUTPUT);
pinMode(Y_DIR, OUTPUT); pinMode(Y_STP, OUTPUT);
pinMode(Z_DIR, OUTPUT); pinMode(Z_STP, OUTPUT);
pinMode(EN, OUTPUT);
digitalWrite(EN, LOW);
}
void loop() {
for (int i = 0; i < steps; i++) {
digitalWrite(Y_DIR, HIGH);
digitalWrite(Y_STP, HIGH);
delay(1);
digitalWrite(Y_STP, LOW);
delay(1);
}
delay (2000);
}

Hi,

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html . Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

What motors are you using?
What motor controllers are you using?

Thanks.. Tom.. :slight_smile:

Oh sorry ! i didin't know this. the next time i will care.

Your pin assignments look like the pin assignments for a grbl shield. Are you using a grbl shield?

I have an Uno with a grbl shield (with DRV8825 drivers) and loaded your code to it and ran the code. The Y motor runs for 50 steps every 2 seconds, so the code "works". How are you powering the steppers? Are you using DRV8825 or A4988 drivers? Have you adjusted the coil current like is shown on this Pololu DRV8825 page or this A4988 page?

Hi,
No problems, can I suggest you adjust the delay(1) times, you are only making 1ms pulses, probably way to short for the stepper and controller.
Start with delay(100);

Tom.. :slight_smile:

Robin2's simple stepper test code should work with any step/dir type driver. If using a grbl shield the enable pin must be set up (declared and pinMode(EN, OUTPUT)) and set LOW.