Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Murach's SQL Server 2012 For Developers

Authors: Bryan Syverson, Joel Murach, Mike Murach

1st Edition

1890774693, 9781890774691

More Books

Students also viewed these Databases questions

Question

Describe the infrastructure trap.

Answered: 1 week ago

Question

=+ How would you advise those problems be resolved?

Answered: 1 week ago