You use the 4th motor (A) just like the other 3 except the step pin for the A is pin 12 and the dir pin is pin 13 once the jumpers are in place. That means that you no longer have the spindle enable or spindle direction control.
#define CW 0
#define CCW 1
const byte stepPin = 12; // x axis > 2, y axis > 3, z axis > 4 a axis > 12
const byte dirPin = 13; // x axis > 5, y axis > 6, z axis > 7 a axis > 13
const byte enablePin = 8; // enable on the CNC shield is held HIGH (disabled) by default
unsigned long stepTime = 2400;
void setup()
{
Serial.begin(115200);
pinMode(stepPin, OUTPUT);
pinMode(dirPin, OUTPUT);
pinMode(enablePin, OUTPUT);
digitalWrite(enablePin, LOW); // enable steppers
digitalWrite(dirPin, CCW);
}
void loop()
{
oneStep();
}
void oneStep()
{
static unsigned long timer = 0;
unsigned long interval = stepTime;
if (micros() - timer >= interval)
{
timer = micros();
digitalWrite(stepPin, HIGH);
delayMicroseconds(10);
digitalWrite(stepPin, LOW);
}
}
If you need a limit (home) switch for the A axis (as well as x, y, z), you will need to use one of the analog pins for the sensor.