 // degree step sizes. Motors with finer step sizes are available but driving them in 
 // quickly using sub-micron steps is a limiting factor. If you want to get up and running 
 // in the shortest time, 0.9 degree motors are suggested. 
-float fullStep[numAxes]={0.9,0.9,0.9}; //In degrees
+float fullStep[maxAxes]={0.9,0.9,0.9,0.9}; //In degrees
 
 // disableWhenStationary
 // bool to tell the system whether or not a motor should be disabled when the stage isn't moving.
 // Disabling will reduce noise but can cause the motors to move to the nearest full step when the
 // power is switched off. Perhaps it makes make sense to do this in X and Y but not Z. 
-bool disableWhenStationary[numAxes]={0,0,0};
-
-
-//------------------------------------------------------------------------------------------------
+bool disableWhenStationary[maxAxes]={0,0,0,0};
+
+
+
+
+//------------------------------------------------------------------------------------------------
+// * Motor control DIO lines
+// Alter the following based on how your system is wired. 
+
+// stepOut
+// One pulse at these pins moves the motor by one step (or one micro-step)
+byte stepOut[maxAxes]={22,24,26,0}; //Set these to the step out pins (ordered X, Y, and Z)
+
+// stepDir
+// These pins tell the Big Easy Driver to which they connect which direction to rotate the motor
+byte stepDir[maxAxes]={23,25,27,0}; //Ordered X, Y, and Z
+
+// enable
+// If these pins are low, the motor is enabled. If high it's disabled. Disabling might decrease 
+// electrical noise but will lead to errors in absolute positioning. 
+byte enable[maxAxes]={28,29,30,0}; //Ordered X, Y, and Z
+
+// The microstep pins.
+// These pins define the microstep size. The MS pins on all axes are wired together.
+byte MS1=45;
+byte MS2=47;
+byte MS3=49;
+
+
+
+//------------------------------------------------------------------------------------------------
+// * AccelStepper 
+// Set up three AccelStepper instances for managing the three axes of motion. There are are a 
+// couple of other ways to issue steps and keep track of the stage position. 
+// 1. Software pulse generation and software stage position counters
+// 2. Hardware timer pulse generation and hardware counter for step pulses. 
+// AccelStepper does a good job and makes the code more compact so we've gone with it.
+AccelStepper stepperX(1, stepOut[0], stepDir[0]); 
+AccelStepper stepperY(1, stepOut[1], stepDir[1]); 
+AccelStepper stepperZ(1, stepOut[2], stepDir[2]); 
+
+//Make an array of pointers to the AccelStepper instances to make loops possible
+AccelStepper *mySteppers[numAxes]={&stepperX, &stepperY, &stepperZ};
+
+
+
+
+//------------------------------------------------------------------------------------------------
+// * Outputs
+// The following are pin definitions of controller outputs. These signal information to the user
+
+byte beepPin=9; //Set this to the pin to which the Piezo buzzer is connected 
+
+// stageLEDs
+// LEDs will light when the stage moves or an axis is reset, 
+// *NOTE: Updating the stage LEDs for hat-stick motions requires fast digital writes as motor speed
+//        is set in a closed-loop based on hat-stick position. So we set the stage LEDs using 
+//        direct port writes. The code expects the LEDS to be on the first 3 pins of port C of the
+//        Mega. You can use a different port (or even different pins on that port), but then you will
+//        have to change the code in pollPS3. Direct port writes on these pins are only implemented 
+//        for the closed-loop hat-stick control code. Elsewhere we use conventional Arduino 
+//        digitalWrites, as these are adequate. 
+//
+// PC0: 37 (X axis)
+// PC1: 36 (Y axis)
+// PC2: 35 (Z axis)
+// PC3: 34 (a good idea to reserve this for a 4th axis, such as a PIFOC)
+byte stageLEDs[4]={37,36,35,35};
+
+
+
+
+
+//------------------------------------------------------------------------------------------------
+// PS3 Controller speed settings
+// The following settings define how the PS3 controller will control the stage. If you don't have a
+// PS3 controller, you can ignore the following 
+
 // * Speed modes (hat-stick)
 //
 // There will be four (coarse to fine) speeds which may be selected via the two shoulder buttons 

//
// The setup function performs basic operations such as defining the DIO direction of each pin, 
// connecting to a serial device, etc. 
HardwareSerial* SerialComms;
#define HARDWARE_SERIAL_PORT Serial1

void setup() {

  //Initialise loop counters

//
//
// The properties of each axis are defined as separate variables (mostly arrays with a length 
// equal to the number of axes). You can have up 4 axes. 

const byte numAxes=3; //Set this to the number of axes on you system 

// axisPresent
// Allows particular axes to be skipped. Useful for testing. 1 means present. 0 means absent. 
// e.g. if you have one axis the following vector might be {1,0,0,0} Although {0,1,0,0} should 
// also work
bool axisPresent[maxAxes]={1,1,1,0}; 


// gearRatio
// Micrometer gear ratios on X,Y,Z in microns per revolution. Unused axes can have any number. 
unsigned short gearRatio[maxAxes]={635,635,250,635}; 


// fullStep
