# Arduino UNO CNC shield - controlling 4 stepper motors

**URL:** <https://forum.arduino.cc/t/arduino-uno-cnc-shield-controlling-4-stepper-motors/913742>\
**Category:** LEDs and Multiplexing\
**Created:** [October 11, 2021, 9:44am UTC](https://forum.arduino.cc/t/arduino-uno-cnc-shield-controlling-4-stepper-motors/913742 "2021-10-11T09:44:26Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![groundFungus](https://avatars.discourse-cdn.com/v4/letter/g/73ab20/32.png) [@groundFungus](https://forum.arduino.cc/u/groundFungus)\
**Post date:** [October 12, 2021, 8:26am UTC](https://forum.arduino.cc/t/arduino-uno-cnc-shield-controlling-4-stepper-motors/913742/4 "2021-10-12T08:26:07Z")

</div>

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.

```cpp
#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.

---

_[View the full topic](https://forum.arduino.cc/t/arduino-uno-cnc-shield-controlling-4-stepper-motors/913742)._
