Adafruit Motor Shield steppers not turning

The Adafruit Motor Shield is connected to 2 steppers which are wired correctly and work when I just use the onestep function. I understand that I cannot drive both at once, so I am using a while loop with two if statements. The Motors were wired:

The left motor was wired:

Green -> m3+
White -> m3-
Red -> m4+
Blue -> m4-

The right motor was wired:

Red -> M2+
Blue -> M2-
Green -> M1+
Black -> M1-

Here is the code:

#include <Wire.h>

//79 steps per half inch
//half inch is a coordinate
//declaring global variables for Hypotenuses (cord lengths)
int leftHyp;
int rightHyp;
int prevX = 0;
int prevY = 0;
//space from shaft to shaft is 30"
//calculating function
void CordCalc(int xCord, int yCord)
{
Serial.begin(9600);
//cords start at 0,0
xCord = xCord - prevX;
yCord = yCord - prevY;
int xSquared = sq(xCord);
int ySquared = sq(yCord);
int addSquares = xSquared + ySquared;
//now for the right
int rightX = 60 - xCord;
int rightXsq = sq(rightX);
int rightSquares = rightXsq + ySquared;
int rightHyp = sqrt(rightSquares);
//leftMotor->step(leftHyp * 79, FORWARD, MICROSTEP);
//rightMotor->step(rightHyp * 79, FORWARD, MICROSTEP);
int lStepsTaken = 0;
int rStepsTaken = 0;
leftHyp = leftHyp * 79;
rightHyp = rightHyp * 79;
bool stepsComplete = false;

//This is the section for moving the Motors
while(stepsComplete == false) {
if(lStepsTaken <= leftHyp) {
leftMotor->onestep(FORWARD,DOUBLE);
lStepsTaken++;
Serial.print("Left");
}

if(rStepsTaken < rightHyp) {
rightMotor->onestep(FORWARD,DOUBLE);
rStepsTaken++;
Serial.print("Right!");
}

if(rStepsTaken >= leftHyp && lStepsTaken >= leftHyp) {
stepsComplete = true;
}
}

int prevY = yCord;
int prevX = xCord;
stepsComplete = false;
}

void setup()
{
// direction from project point of view
int leftLength = 0;
int rightLength = 0;
leftMotor->setSpeed(122);
rightMotor->setSpeed(122);
Serial.begin(9600);

CordCalc(15, 15);
}

void loop()
{
}

Loop is empty on purpose because only need to move to coordinates once.

– user31481
Feb 13 '18 at 18:05
• you really need to format your code properly. ... correct indentation helps a lot when debugging code Feb 13 '18 at 19:55
• @jsotola. Solved that for you. Ho, my eyes!
– user31481
Feb 13 '18 at 20:46