Question: How to write codes, to move both motor, for example y and z axis at same with the following codes, in other words Simultaneously) and

How to write codes, to move both motor, for example y and z axis at same with the following codes, in other words Simultaneously) and the function to stop the loop at the end.

#include const int Z_stepPin = 9; const int Y_stepPin = 7; const int X_stepPin = 11; const int Z_dirPin = 8; const int Y_dirPin = 6; const int X_dirPin = 12;

void setup() { pinMode(Z_stepPin,OUTPUT); pinMode(Y_stepPin,OUTPUT); pinMode(X_stepPin,OUTPUT); pinMode(Z_dirPin,OUTPUT); pinMode(Y_dirPin,OUTPUT); pinMode(X_dirPin,OUTPUT); digitalWrite(Z_stepPin,LOW); digitalWrite(Y_stepPin,LOW); digitalWrite(X_stepPin,LOW); digitalWrite(Z_dirPin,LOW); digitalWrite(Y_dirPin,LOW); digitalWrite(X_dirPin,LOW); } void loop() {

digitalWrite(X_dirPin,LOW); // anticlockwise direction 1 for(int x = 0; x < 17000; x++) { digitalWrite(X_stepPin,HIGH); delayMicroseconds(2); digitalWrite(X_stepPin,LOW); delayMicroseconds(750); } delay(1000); digitalWrite(Z_dirPin,LOW); // anticlockwise direction 2 for(int x = 0; x < 5000; x++) { digitalWrite(Z_stepPin,HIGH); delayMicroseconds(2); digitalWrite(Z_stepPin,LOW); delayMicroseconds(740); } delay(1000);

digitalWrite(X_dirPin,HIGH); // anticlockwise direction 3 for(int x = 0; x < 17000; x++) { digitalWrite(X_stepPin,HIGH); delayMicroseconds(2); digitalWrite(X_stepPin,LOW); delayMicroseconds(750); } delay(1000);

digitalWrite(Y_dirPin,HIGH); // clockwise driection 4 for(int x = 0; x < 15350; x++) { digitalWrite(Y_stepPin,HIGH); delayMicroseconds(2); digitalWrite(Y_stepPin,LOW); delayMicroseconds(750); } delay(1000);

digitalWrite(Z_dirPin,HIGH); // anticlockwise direction 5 for(int x = 0; x < 23000; x++) { digitalWrite(Z_stepPin,HIGH); delayMicroseconds(2); digitalWrite(Z_stepPin,LOW); delayMicroseconds(740); } delay(1000);

digitalWrite(X_dirPin,LOW); // anticlockwise direction 6 for(int x = 0; x < 17000; x++) { digitalWrite(X_stepPin,HIGH); delayMicroseconds(2); digitalWrite(X_stepPin,LOW); delayMicroseconds(750); } delay(1000); // Half second delay

digitalWrite(Z_dirPin,HIGH); // anticlockwise direction 7 for(int x = 0; x < 5000; x++) { digitalWrite(Z_stepPin,HIGH); delayMicroseconds(2); digitalWrite(Z_stepPin,LOW); delayMicroseconds(740); } delay(1000); digitalWrite(X_dirPin,HIGH); // anticlockwise direction 8 for(int x = 0; x < 17000; x++) { digitalWrite(X_stepPin,HIGH); delayMicroseconds(2); digitalWrite(X_stepPin,LOW); delayMicroseconds(750); } delay(1000);

digitalWrite(X_dirPin,LOW); // anticlockwise direction 1 for(int x = 0; x < 17000; x++) { digitalWrite(X_stepPin,HIGH); delayMicroseconds(2); digitalWrite(X_stepPin,LOW); delayMicroseconds(750); } delay(1000); digitalWrite(Z_dirPin,LOW); // anticlockwise direction 2 for(int x = 0; x < 5000; x++) { digitalWrite(Z_stepPin,HIGH); delayMicroseconds(2); digitalWrite(Z_stepPin,LOW); delayMicroseconds(740); } delay(1000);

digitalWrite(X_dirPin,HIGH); // anticlockwise direction 3 for(int x = 0; x < 17000; x++) { digitalWrite(X_stepPin,HIGH); delayMicroseconds(2); digitalWrite(X_stepPin,LOW); delayMicroseconds(750); } delay(1000);

digitalWrite(Y_dirPin,LOW); // clockwise driection 4 for(int x = 0; x < 15350; x++) { digitalWrite(Y_stepPin,HIGH); delayMicroseconds(2); digitalWrite(Y_stepPin,LOW); delayMicroseconds(750); } delay(1000);

digitalWrite(Z_dirPin,LOW); // anticlockwise direction 5 for(int x = 0; x < 23000; x++) { digitalWrite(Z_stepPin,HIGH); delayMicroseconds(2); digitalWrite(Z_stepPin,LOW); delayMicroseconds(740); } delay(1000);

digitalWrite(X_dirPin,LOW); // anticlockwise direction 6 for(int x = 0; x < 17000; x++) { digitalWrite(X_stepPin,HIGH); delayMicroseconds(2); digitalWrite(X_stepPin,LOW); delayMicroseconds(750); } delay(1000); // Half second delay

digitalWrite(Z_dirPin,HIGH); // anticlockwise direction 7 for(int x = 0; x < 5000; x++) { digitalWrite(Z_stepPin,HIGH); delayMicroseconds(2); digitalWrite(Z_stepPin,LOW); delayMicroseconds(740); } delay(1000); digitalWrite(X_dirPin,HIGH); // anticlockwise direction 8 for(int x = 0; x < 17000; x++) { digitalWrite(X_stepPin,HIGH); delayMicroseconds(2); digitalWrite(X_stepPin,LOW); delayMicroseconds(750); } delay(1000);

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!