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
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started