Here is my edited Initial Height Sense.
Pin 3(INPUT) is the Arc Start from mach3 or what ever controller you use. Pin 5(OUTPUT) is the Arc Start command that gets sent out once the arduino finishes its program. Once I get enough money I am going to buy the motor kit right away and try to get this working with the Gecko G540. I should be able to just take the Z-step and Z-direction and HIGH or LOW the direction and just pulse the step until the conditions are met.
Code:
#include <AFMotor.h>
AF_Stepper motor(48, 1);
int mybit = 0;
void setup() {
pinMode(2, INPUT);
pinMode(3, INPUT);
pinMode(5, OUTPUT);
motor.setSpeed(150);
}
void loop() {
if (digitalRead(3) == HIGH){
bitClear(mybit,1);
digitalWrite(5, LOW);
}
else if (bitRead(mybit,1) == 1){
}
else if (digitalRead(2) == LOW)
{motor.step(1, BACKWARD, DOUBLE);
}
else {motor.step(64, FORWARD, DOUBLE);
bitSet(mybit,1);
motor.release();
digitalWrite(5, HIGH);
}
}