I'm using Arduino Mega 2560, A4988 motor driver for 5 stepper motors. There are X1, X2, Y, Z, A axis, and if I control Y and Z at once, it works. But when I just change axis from Y&Z to X1&X2, only X1 stepper motor spins. X1&X2 need to move at once(simultaneously) due to they are connected in single bar.
My Arduino IDE code is,
==============================
const int X2step = 5;
const int X2dir = 4;
const int X1step = 3;
const int X1dir = 2;
void setup() {
pinMode(X1step,OUTPUT);
pinMode(X1dir,OUTPUT);
pinMode(X2step,OUTPUT);
pinMode(X2dir,OUTPUT);
}
void loop() {
digitalWrite(X1dir,HIGH);
digitalWrite(X2dir,HIGH);
for(int x = 0; x < 4000; x++) {
digitalWrite(X1step,HIGH);
delayMicroseconds(2000);
digitalWrite(X1step,LOW);
delayMicroseconds(2000);
digitalWrite(X2step,HIGH);
delayMicroseconds(2000);
digitalWrite(X2step,LOW);
delayMicroseconds(2000);
}
delay(1000);
digitalWrite(X1dir,LOW);
digitalWrite(X2dir,LOW);
for(int x = 0; x < 4000; x++) {
digitalWrite(X1step,HIGH);
delayMicroseconds(2000);
digitalWrite(X1step,LOW);
delayMicroseconds(2000);
digitalWrite(X2step,HIGH);
delayMicroseconds(2000);
digitalWrite(X2step,LOW);
delayMicroseconds(2000);
}
exit(0);
=================================================
Any suggestion would be helpful for me. Thanks.
}
for theloop()
function in your code (which would've been nearly impossible to detect without the code being indented&so on). Sorry to be pedantic about this. Just saying that people can only help you, if you help them see your problem clearly.:)