Zookal
Zookal

We’d love to hear any feedback or comment from you!

© 2011-2021 Zookal Pty Ltd

View question and answer

From our collection of questions and answers
Engineering · Computer Science
Question details

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 <Stepper.h>
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);

}

Answer
Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.

Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.