I have a CNC shield setup with 3 motors
I want to be able to pass a byte value (Position) from a text file on my PC to Ariduno while its running. It will wait until it recieves a value != 0 and if statements will determine how far the motors move, but im unsure on how to achieve this. Also might send a "at home position" signal to the PC so it knows to send the next byte value.
There is a large portion of the code im using ommited here
void step (boolean dir, byte dirPin, byte stepperPin, int steps) {
digitalWrite (dirPin, dir);
delay (50);
for (int i = 0; i < steps; i++) {
digitalWrite (stepperPin, HIGH);
delayMicroseconds (800);
digitalWrite (stepperPin, LOW);
delayMicroseconds (800);
}
}
void loop () {
byte Position = 0;
//Wait for obtained data here from PC and change Position value
if (Position != 0){
if (Position == 1){step (true, X_DIR, X_STP, 100); step (true, Y_DIR, Y_STP, 0);}
if (Position == 10){step (true, X_DIR, X_STP, 400); step (true, Y_DIR, Y_STP, 200);}
if (Position == 23){step (true, X_DIR, X_STP, 500); step (true, Y_DIR, Y_STP, 600);}
//ect...