Having trouble getting the code to compile, and motor control

Attached below is the .ino profile. I’m struggling with a few things in this project, namely getting it to compile, controlling the order and parts of the code that happens each time it cycles, and figuring out how to individually control each stepper motor. speed and direction.

Any help in any of the topics would be greatly appreciated, going into week 2 of working on the code.

while_p3.ino (6.85 KB)

More members will see your code if you post your code as described in the forum guidelines.

Line 80:

    if (pressState == HIGH and PartsensPin == HIGH); {

should be:

    if (pressState == HIGH and PartsensPin == HIGH) {

Line 97:

      powerOn = false

should be:

      powerOn = false;

Line 108:

    if (SolASensIn == HIGH and SolASensOut == LOW and SolBSensIn == HIGH and SolBSensOut == LOW and PartsensPin == HIGH and pressState == HIGH and PartsensPin == HIGH);  {

should be:

    if (SolASensIn == HIGH and SolASensOut == LOW and SolBSensIn == HIGH and SolBSensOut == LOW and PartsensPin == HIGH and pressState == HIGH and PartsensPin == HIGH)  {

Do you have a specification, timing diagram or flowchart for the sequence(s) that you are trying to implement?

Not yet, I'm working on that currently. as well as investigating the corrections from the post before

  // Lock In Original State Of each Sensor
  int PartsensPin = digitalRead(PartsensPin);
  int SolASensIn = digitalRead(SolASensIn);
  int SolASensOut = digitalRead(SolASensOut);
  int SolBSensIn = digitalRead(SolBSensIn);
  int SolBSensOut = digitalRead(SolBSensOut);

You are creating local variables in loop() and trying to use the global variable of the same name to initialize them. That doesn’t work and you get a pile of warnings that you are using an uninitialized variable (to initialize itself).

Change code so the local variables don’t have the same name as the global constants

  // Lock In Original State Of each Sensor
  int partsensPin = digitalRead(PartsensPin);
  int solASensIn = digitalRead(SolASensIn);
  int solASensOut = digitalRead(SolASensOut);
  int solBSensIn = digitalRead(SolBSensIn);
  int solBSensOut = digitalRead(SolBSensOut);

This version compiles without error:

#include <Stepper.h>


// constant variables


const int PartsensPin = 40;                   // Part in nest Sensor
const int SolenoidAPin = 1;                  // Solenoid A Pin Right Side
const int SolASensInPin = 2;                    // Solenoid A Sensor 1
const int SolASensOutPin = 3;                   // Solenoid A Sensor 2
const int SolenoidBPin = 4;                  // Solenoid B Pin Left Side
const int SolBSensInPin = 5;                    // Solenoid B Sensor 1
const int SolBSensOutPin = 6;                   // Solenoid B Sensor 2
const int DirMoter1 = 7;                       // motor 1 Dir pin Right
const int DirMoter2 = 8;                       // motor 2 Dir pin Right
const int DirMoter3 = 9;                       // motor 3 Dir pin Left
const int DirMoter4 = 10;                      // motor 4 Dir pin left
const int EjectionSolenoid = 11;            // ejection solinoid under nest
const int PressInPin = 44;                      // press start signal
const int PressOutPin = 13;                     // send finished or empty nest signal to press
const int StepPin1 = 14;                        // driver PUL motor 1
const int StepPin2 = 15;                        // driver PUL motor 2
const int StepPin3 = 16;                        // driver PUL motor 3
const int StepPin4 = 17;                        // driver PUL motor 4
const int RsFbs = 18;                        // Right Side Front Bump Switch for signalling arm back
const int RsBbs = 19;                        // Right Side Back Bump Switch for signaling arm is back
const int LsFbs = 20;                        // Left Side Front bump switch for signaling arm back
const int LsBbs = 21;                        // Left Side Back Bump Switch for signaling arm is back


int pd = 500;                             // Pulse Delay period
int pressState = 0;                       // Variable For reading press status
int prevpressState;
const int stepsPerRevolution = 200;          // Stepps for revolution
// initialize the stepper library on pins 7 through 10 and 14 through 17:


bool powerOn = false;
boolean setdir = LOW;                     // Set Direction
Stepper myStepper(stepsPerRevolution, 14, 15, 16, 17);
void revmotor ()
{
  setdir = !setdir;
}
void setup()
{
  Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
  //setup to be adjusted 13 total
  // set the speed at 60rpm:
  myStepper.setSpeed(60);
  pinMode(PressInPin, INPUT_PULLUP);             // Press signal input
  pinMode(PartsensPin, INPUT_PULLUP);         // part in nest sensor
  pinMode(SolASensInPin, INPUT_PULLUP);          // solenoid Sensor A In
  pinMode(SolASensOutPin, INPUT_PULLUP);         // solenoid Sensor A Out
  pinMode(SolBSensInPin, INPUT_PULLUP);          // Solenoid Sensor B In
  pinMode(SolBSensOutPin, INPUT_PULLUP);         // Solenoid sensor B Out
  pinMode(RsFbs, INPUT_PULLUP);               // Right Side Front Bumper Switch
  pinMode(RsBbs, INPUT_PULLUP);               // Right Side Back Bumper Switch
  pinMode(LsFbs, INPUT_PULLUP);               // Left Side Front Bump Switch
  pinMode(LsBbs, INPUT_PULLUP);               // Left Side Back Bump Switch


  pinMode(SolenoidAPin, OUTPUT);              // solonoid A is outputting
  pinMode(SolenoidBPin, OUTPUT);              // solonoid B is outputting
  pinMode(EjectionSolenoid, OUTPUT);          // Part ejection Solenoid
  pinMode(PressOutPin, OUTPUT);                  // Output to press


  pinMode(DirMoter1, OUTPUT);                    //  arm motor 1 LEFT
  pinMode(DirMoter2, OUTPUT);                    //  Saw motor LEFT
  pinMode(DirMoter3, OUTPUT);                    //  arm motor 2 RIGHT
  pinMode(DirMoter4, OUTPUT);                    //  arm motor RIGHT
  pinMode(StepPin1, OUTPUT);                   // PUL PIN out M1
  pinMode(StepPin2, OUTPUT);                   // PUL PIN out M2
  pinMode(StepPin3, OUTPUT);                   // PUL PIN out M3
  pinMode(StepPin4, OUTPUT);                   // PUL PIN out M4
  prevpressState = digitalRead(PressInPin);
}


void loop()
{
  // Lock In Original State Of each Sensor
  int partsensPin = digitalRead(PartsensPin);
  int solASensIn = digitalRead(SolASensInPin);
  int solASensOut = digitalRead(SolASensOutPin);
  int solBSensIn = digitalRead(SolBSensInPin);
  int solBSensOut = digitalRead(SolBSensOutPin);
  int pressState = digitalRead(PressInPin);
  // Press Input State :
  if (pressState != prevpressState )
  {
    // powerswitch state change
    if (pressState == HIGH and PartsensPin == HIGH)
    {
      //Press On
      Serial.println("Press ON");
      delay(750);
      digitalWrite(SolenoidAPin, HIGH);      // Once the press says go, it waits till the part is sensed in the nest
      digitalWrite(SolenoidBPin, HIGH);
      Serial.println(" Part Is In Nest ");
      powerOn = true;
    }
    else
    {
      //press off
      Serial.println( "Press Off" );
      delay(500);
      digitalWrite(SolenoidAPin, LOW);
      digitalWrite(SolenoidBPin, LOW);
      powerOn = false;
      Serial.print(" No Part, back to start");    //the loop, until the parts in and press says go, code will not continue
    }
    delay(25);  // debounce
  }
  //  cutting phase
  prevpressState = pressState;




  // only check sensors if powerOn is true
  if (powerOn == true)
  {
    if (solASensIn == HIGH and solASensOut == LOW and solBSensIn == HIGH and
        solBSensOut == LOW and partsensPin == HIGH and pressState == HIGH)
    {
      // if all the sensors say the clamps are down and part is in nest, start the saws
      delay (500);
      myStepper.step(7200);
      delay (25); // debounce
      digitalWrite(DirMoter2, HIGH);            // set direction
      digitalWrite(DirMoter4, HIGH);
      digitalWrite(StepPin2, LOW);                 // Start the stepper Motor saws
      digitalWrite(StepPin4, LOW);
      Serial.println (" Start saws ");
      digitalWrite(StepPin1, HIGH);
      digitalWrite(StepPin3, HIGH);
      digitalWrite(DirMoter1, HIGH);                // start the cutting motion
      digitalWrite(DirMoter3, HIGH);
      delay(500);
      if (RsFbs == HIGH and LsFbs == HIGH)      // cuts are done and the arm can move back
      {
        digitalWrite(StepPin1, setdir);
        digitalWrite(StepPin3, setdir);
        digitalWrite(DirMoter1, LOW);                // reverse the cutting motion
        digitalWrite(DirMoter3, LOW);
        digitalWrite(StepPin2, LOW);                 // Start the stepper Motor saws
        digitalWrite(StepPin4, LOW);
        delay(3000);                                             //add ejection, bellow is a start code
        digitalWrite(EjectionSolenoid, HIGH); //push part out
        delay (750);
        digitalWrite(EjectionSolenoid, LOW); //bring nest base back in




      }
      else
      {
        digitalWrite(StepPin2, HIGH);                 // Start the stepper Motor saws
        digitalWrite(StepPin4, HIGH);
        Serial.println (" keep sawing ");


      }
    }
  }
}

Awsome I appreciate it, about to go through everything ^ just sent right now. Attached is a basic diagram I threw together explaining the code and its function/ use case.

#include <Stepper.h>


// constant variables


const int PartsensPin = 40;                   // Part in nest Sensor
const int SolenoidAPin = 1;                  // Solenoid A Pin Right Side
const int SolASensInPin = 2;                    // Solenoid A Sensor 1
const int SolASensOutPin = 3;                   // Solenoid A Sensor 2
const int SolenoidBPin = 4;                  // Solenoid B Pin Left Side
const int SolBSensInPin = 5;                    // Solenoid B Sensor 1
const int SolBSensOutPin = 6;                   // Solenoid B Sensor 2
const int DirMoter1 = 7;                       // motor 1 Dir pin Right
const int DirMoter2 = 8;                       // motor 2 Dir pin Right
const int DirMoter3 = 9;                       // motor 3 Dir pin Left
const int DirMoter4 = 10;                      // motor 4 Dir pin left
const int EjectionSolenoid = 11;            // ejection solinoid under nest
const int PressInPin = 44;                      // press start signal
const int PressOutPin = 13;                     // send finished or empty nest signal to press
const int StepPin1 = 14;                        // driver PUL motor 1
const int StepPin2 = 15;                        // driver PUL motor 2
const int StepPin3 = 16;                        // driver PUL motor 3
const int StepPin4 = 17;                        // driver PUL motor 4
const int RsFbs = 18;                        // Right Side Front Bump Switch for signalling arm back
const int RsBbs = 19;                        // Right Side Back Bump Switch for signaling arm is back
const int LsFbs = 20;                        // Left Side Front bump switch for signaling arm back
const int LsBbs = 21;                        // Left Side Back Bump Switch for signaling arm is back


int pd = 500;                             // Pulse Delay period
int pressState = 0;                       // Variable For reading press status
int prevpressState;
const int stepsPerRevolution = 400;          // Stepps for revolution
// initialize the stepper library on pins 7 through 10 and 14 through 17:


bool powerOn = false;
boolean setdir = LOW;                     // Set Direction
Stepper myStepper(stepsPerRevolution, 14, 15, 16, 17);
void revmotor ()
{
  setdir = !setdir;
}
void setup()
{
  Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
  //setup to be adjusted 13 total
  // set the speed at 60rpm:
  myStepper.setSpeed(60);
  pinMode(PressInPin, INPUT_PULLUP);             // Press signal input
  pinMode(PartsensPin, INPUT_PULLUP);         // part in nest sensor
  pinMode(SolASensInPin, INPUT_PULLUP);          // solenoid Sensor A In
  pinMode(SolASensOutPin, INPUT_PULLUP);         // solenoid Sensor A Out
  pinMode(SolBSensInPin, INPUT_PULLUP);          // Solenoid Sensor B In
  pinMode(SolBSensOutPin, INPUT_PULLUP);         // Solenoid sensor B Out
  pinMode(RsFbs, INPUT_PULLUP);               // Right Side Front Bumper Switch
  pinMode(RsBbs, INPUT_PULLUP);               // Right Side Back Bumper Switch
  pinMode(LsFbs, INPUT_PULLUP);               // Left Side Front Bump Switch
  pinMode(LsBbs, INPUT_PULLUP);               // Left Side Back Bump Switch


  pinMode(SolenoidAPin, OUTPUT);              // solonoid A is outputting
  pinMode(SolenoidBPin, OUTPUT);              // solonoid B is outputting
  pinMode(EjectionSolenoid, OUTPUT);          // Part ejection Solenoid
  pinMode(PressOutPin, OUTPUT);                  // Output to press


  pinMode(DirMoter1, OUTPUT);                    //  arm motor 1 LEFT
  pinMode(DirMoter2, OUTPUT);                    //  Saw motor LEFT
  pinMode(DirMoter3, OUTPUT);                    //  arm motor 2 RIGHT
  pinMode(DirMoter4, OUTPUT);                    //  arm motor RIGHT
  pinMode(StepPin1, OUTPUT);                   // PUL PIN out M1
  pinMode(StepPin2, OUTPUT);                   // PUL PIN out M2
  pinMode(StepPin3, OUTPUT);                   // PUL PIN out M3
  pinMode(StepPin4, OUTPUT);                   // PUL PIN out M4
  prevpressState = digitalRead(PressInPin);
}


void loop()
{
  // Lock In Original State Of each Sensor
  int partsensState = digitalRead(PartsensPin);
  int solAState = digitalRead(SolASensInPin);
  int solBState = digitalRead(SolBSensInPin);
  int pressState = digitalRead(PressInPin);
  // Press Input State :
  if (pressState != prevpressState )
  {
    // powerswitch state change
    if (pressState == HIGH and partsensState == HIGH)
    {
      //Press On
      Serial.println("Press ON");
      delay(750);
      digitalWrite(SolenoidAPin, HIGH);      // Once the press says go, it waits till the part is sensed in the nest
      digitalWrite(SolenoidBPin, HIGH);
      Serial.println(" Part Is In Nest ");
      powerOn = true;
    }
    else
    {
      //press off
      Serial.println( "Press Off" );
      delay(500);
      digitalWrite(SolenoidAPin, LOW);
      digitalWrite(SolenoidBPin, LOW);
      powerOn = false;
      Serial.print(" No Part, back to start");    //the loop, until the parts in and press says go, code will not continue
    }
    delay(25);  // debounce
  }
  //  cutting phase
  prevpressState = pressState;


 

  // only check sensors if powerOn is true
  if (powerOn == true)
  {
    // make like magent fixture, listing A B C
// int partsensState = digitalRead(PartsensPin);
//  int solAState = digitalRead(SolASensInPin);
//  int solBState = digitalRead(SolBSensInPin);
//  int pressState = digitalRead(PressInPin);

    Serial.print( "A: "); Serial.print(PartsensPin);
    Serial.print( ", B: " ); Serial.print(solAState);
    Serial.print( ", C: " ); Serial.print(solBState);
    Serial.print( ", D: " ); Serial.print(pressState);
    Serial.println();
    if (solAState == HIGH and solBState == HIGH and partsensState == HIGH and pressState == HIGH)
    {
      // if all the sensors say the clamps are down and part is in nest, start the saws
      delay (500);
      myStepper.step(12000);
      delay (25); // debounce
      digitalWrite(DirMoter2, HIGH);            // set direction
      digitalWrite(DirMoter4, HIGH);
      digitalWrite(StepPin2, LOW);                 // Start the stepper Motor saws
      digitalWrite(StepPin4, LOW);
      Serial.println (" Start saws ");
      digitalWrite(StepPin1, HIGH);
      digitalWrite(StepPin3, HIGH);
      digitalWrite(DirMoter1, HIGH);                // start the cutting motion
      digitalWrite(DirMoter3, HIGH);
      delay(500);
      if (RsFbs == HIGH and LsFbs == HIGH)      // cuts are done and the arm can move back
      {
        digitalWrite(StepPin1, setdir);
        digitalWrite(StepPin3, setdir);
        digitalWrite(DirMoter1, LOW);                // reverse the cutting motion
        digitalWrite(DirMoter3, LOW);
        digitalWrite(StepPin2, LOW);                 // Start the stepper Motor saws
        digitalWrite(StepPin4, LOW);
        delay(3000);                                             //add ejection, bellow is a start code
        digitalWrite(EjectionSolenoid, HIGH); //push part out
        delay (750);
        digitalWrite(EjectionSolenoid, LOW); //bring nest base back in
      }
      else
      {
        digitalWrite(StepPin2, HIGH);                 // Start the stepper Motor saws
        digitalWrite(StepPin4, HIGH);
        Serial.println (" keep sawing ");
      }
    }
  }
}

Above is what I have so far and it's all working! Thanks Everyone!

The last question I have is how do I individually control the stepper motors. I'm going to do some research my self but if anyone has the knowledge they would want to share please do!

@jefhod

Other post/duplicate DELETED
Please do NOT cross post / duplicate as it wastes peoples time and efforts to have more than one post for a single topic.

Continued cross posting could result in a time out from the forum.

Could you also take a few moments to Learn How To Use The Forum.

Other general help and troubleshooting advice can be found here.
It will help you get the best out of the forum in the future.

jefhod:
The last question I have is how do I individually control the stepper motors.

Each stepper driver has a Direction pin and a Step pin. Set the Direction pin to the direction you want to move and send a pulse to the Step pin each time you want to move one step. The stepper that moves is the one you sent the Step pulse to.

// constant variables
#include <Stepper.h>

const int PartsensPin = 40;                   // Part in nest Sensor
const int SolenoidAPin = 1;                  // Solenoid A Pin Right Side
const int SolASensInPin = 2;                    // Solenoid A Sensor 1
const int SolASensOutPin = 3;                   // Solenoid A Sensor 2
const int SolenoidBPin = 4;                  // Solenoid B Pin Left Side
const int SolBSensInPin = 5;                    // Solenoid B Sensor 1
const int SolBSensOutPin = 6;                   // Solenoid B Sensor 2
const int DirMoter1 = 7;                       // motor 1 Dir pin Right
const int DirMoter2 = 8;                       // motor 2 Dir pin Right
const int DirMoter3 = 9;                       // motor 3 Dir pin Left
const int DirMoter4 = 10;                      // motor 4 Dir pin left
const int EjectionSolenoid = 11;            // ejection solinoid under nest
const int PressInPin = 44;                      // press start signal
const int PressOutPin = 13;                     // send finished or empty nest signal to press
const int StepPin1 = 14;                        // driver PUL motor 1
const int StepPin2 = 15;                        // driver PUL motor 2
const int StepPin3 = 16;                        // driver PUL motor 3
const int StepPin4 = 17;                        // driver PUL motor 4
const int RsFbs = 18;                        // Right Side Front Bump Switch for signalling arm back
const int RsBbs = 19;                        // Right Side Back Bump Switch for signaling arm is back
const int LsFbs = 20;                        // Left Side Front bump switch for signaling arm back
const int LsBbs = 21;                        // Left Side Back Bump Switch for signaling arm is back


int pd = 500;                             // Pulse Delay period
int pressState = 0;                       // Variable For reading press status
int prevpressState;
const int stepsPerRevolution = 5000;   // Stepps for revolution
// initialize the stepper library on pins 7 through 10 and 14 through 17:
Stepper myStepper(stepsPerRevolution, 14, 15, 16, 17);
bool powerOn = false;
boolean setdir = LOW;                     // Set Direction
void revmotor ()
{
  setdir = !setdir;
}
void setup()
{
  Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
  //setup to be adjusted 13 total
  // set the speed at 60rpm:
  pinMode(PressInPin, INPUT_PULLUP);             // Press signal input
  pinMode(PartsensPin, INPUT_PULLUP);         // part in nest sensor
  pinMode(SolASensInPin, INPUT_PULLUP);          // solenoid Sensor A In
  pinMode(SolASensOutPin, INPUT_PULLUP);         // solenoid Sensor A Out
  pinMode(SolBSensInPin, INPUT_PULLUP);          // Solenoid Sensor B In
  pinMode(SolBSensOutPin, INPUT_PULLUP);         // Solenoid sensor B Out
  pinMode(RsFbs, INPUT_PULLUP);               // Right Side Front Bumper Switch
  pinMode(RsBbs, INPUT_PULLUP);               // Right Side Back Bumper Switch
  pinMode(LsFbs, INPUT);               // Left Side Front Bump Switch
  pinMode(LsBbs, INPUT);               // Left Side Back Bump Switch


  pinMode(SolenoidAPin, OUTPUT);              // solonoid A is outputting
  pinMode(SolenoidBPin, OUTPUT);              // solonoid B is outputting
  pinMode(EjectionSolenoid, OUTPUT);          // Part ejection Solenoid
  pinMode(PressOutPin, OUTPUT);                  // Output to press


  pinMode(DirMoter1, OUTPUT);                    //  arm motor 1 LEFT
  pinMode(DirMoter2, OUTPUT);                    //  Saw motor LEFT
  pinMode(DirMoter3, OUTPUT);                    //  arm motor 2 RIGHT
  pinMode(DirMoter4, OUTPUT);                    //  arm motor RIGHT
  pinMode(StepPin1, OUTPUT);                   // PUL PIN out M1
  pinMode(StepPin2, OUTPUT);                   // PUL PIN out M2
  pinMode(StepPin3, OUTPUT);                   // PUL PIN out M3
  pinMode(StepPin4, OUTPUT);                   // PUL PIN out M4
  prevpressState = digitalRead(PressInPin);
#define SPD 1200
#define SLW_DWN_SPD 3000
}
//Homing sequence

void loop()
{
  // Lock In Original State Of each Sensor
  int partsensState = digitalRead(PartsensPin);
  int solAState = digitalRead(SolASensInPin);
  int solBState = digitalRead(SolBSensInPin);
  int pressState = digitalRead(PressInPin);
  int RsFbsstate = digitalRead(RsFbs);
  int LsFbsstate = digitalRead(LsFbs);
  int RsBbsstate = digitalRead(RsBbs);
  int LsBbsstate = digitalRead(LsBbs);
  // Press Input State :
  if (pressState != prevpressState )
  {
    // powerswitch state change
    if (pressState == HIGH and partsensState == HIGH)
    {
      //Press On
      Serial.println("Press ON");
      delay(750);
      digitalWrite(SolenoidAPin, HIGH);      // Once the press says go, it waits till the part is sensed in the nest
      digitalWrite(SolenoidBPin, HIGH);
      Serial.println(" Part Is In Nest ");
      powerOn = true;
    }
    else
    {
      //press off
      Serial.println( "Press Off" );
      delay(500);
      digitalWrite(SolenoidAPin, LOW);
      digitalWrite(SolenoidBPin, LOW);
      powerOn = false;
      Serial.print(" No Part, back to start");    //the loop, until the parts in and press says go, code will not continue
    }
    delay(25);  // debounce
  }
  //  cutting phase
  prevpressState = pressState;
  // only check sensors if powerOn is true
  if (powerOn == true)
  {
    // make like magent fixture, listing A B C
    // int partsensState = digitalRead(PartsensPin);
    //  int solAState = digitalRead(SolASensInPin);
    //  int solBState = digitalRead(SolBSensInPin);
    //  int pressState = digitalRead(PressInPin);
 
    Serial.print( "A: "); Serial.print(PartsensPin);
    Serial.print( ", B: " ); Serial.print(solAState);
    Serial.print( ", C: " ); Serial.print(solBState);
    Serial.print( ", D: " ); Serial.print(pressState);
    Serial.println();
    if (solAState == HIGH and solBState == HIGH and partsensState == HIGH and pressState == HIGH)
    {
      // if all the sensors say the clamps are down and part is in nest, start the saws
      if ((digitalRead(RsFbs) == LOW) && (digitalRead(LsFbs) == LOW))
      {
        myStepper.step(7200);
        Serial.println (" time to cutty");
        digitalWrite(DirMoter2, HIGH);            // set direction
        digitalWrite(DirMoter4, HIGH);
        digitalWrite(StepPin2, HIGH);
        digitalWrite(StepPin4, HIGH);
        Serial.println (" Start saws ");
        digitalWrite(StepPin1, HIGH);
        digitalWrite(StepPin3, HIGH);
        digitalWrite(DirMoter1, HIGH);                // start the cutting motion
        digitalWrite(DirMoter3, HIGH);
      }
      if ((digitalRead(RsFbs) == HIGH) && (digitalRead(LsFbs) == HIGH))     // cuts are done and the arm can move back
      {
        myStepper.step(3000);
        Serial.println("Time to reset");
        digitalWrite(StepPin2, setdir);
        digitalWrite(StepPin4, setdir);
        digitalWrite(DirMoter2, LOW);                // reverse the cutting motion
        digitalWrite(DirMoter4, LOW);
        digitalWrite(StepPin2, HIGH);           // Start the stepper Motor saws
        digitalWrite(StepPin4, HIGH);
      }
      else if 
      ((digitalRead(RsFbs)== LOW) && (digitalRead(LsFbs) == LOW) && (digitalRead(RsBbs)== LOW) && (digitalRead(LsBbs)== LOW))
      {
         myStepper.step(3000);
        Serial.println("Time to reset");
        digitalWrite(StepPin1, setdir);
        digitalWrite(StepPin3, setdir);
        digitalWrite(DirMoter2, LOW);                // reverse the cutting motion
        digitalWrite(DirMoter4, LOW);
        digitalWrite(StepPin2, HIGH);           
        digitalWrite(StepPin4, HIGH);
      }
      else if
      ((digitalRead(RsFbs)== LOW) and (digitalRead(LsFbs)== LOW) and (digitalRead(RsBbs)== HIGH) and (digitalRead(LsBbs)== HIGH))
      {
      Serial.println( "Oh NO" );
      delay(500);
      digitalWrite(SolenoidAPin, LOW);
      digitalWrite(SolenoidBPin, LOW);
      delay(250);
      //add in clamp lifting before ejection
        digitalWrite(EjectionSolenoid, HIGH); //push part out
        delay (750);
        digitalWrite(EjectionSolenoid, LOW); //bring nest base back in
      }

    }
  }
}

Attached is what I've got so far, I'm running into a few issues though, first is that the code seems to keep jumping from the 5th if statement to the last if-else statement in the code. I'm struggling to have it go continuously until the RsFbs and LsFbs switches are hit.

You have:

const int SolenoidAPin = 1;                  // Solenoid A Pin Right Side

void setup()
{
  Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
  pinMode(SolenoidAPin, OUTPUT);

You can't use Pin 1 for both SolenoidAPin and Serial.

const int StepPin1 = 14;                        // driver PUL motor 1
const int StepPin2 = 15;                        // driver PUL motor 2
const int StepPin3 = 16;                        // driver PUL motor 3
const int StepPin4 = 17;                        // driver PUL motor 4

// initialize the stepper library on pins 7 through 10 and 14 through 17:
Stepper myStepper(stepsPerRevolution, 14, 15, 16, 17);


void setup()
{
  pinMode(StepPin1, OUTPUT);                   // PUL PIN out M1
  pinMode(StepPin2, OUTPUT);                   // PUL PIN out M2
  pinMode(StepPin3, OUTPUT);                   // PUL PIN out M3
  pinMode(StepPin4, OUTPUT);                   // PUL PIN out M4

No need to set pinMode() on the stepper pins. That's part of the job of the Stepper library.

You should probably have used the pin names in the declaration of myStepper. It's good that you define names for your pins but if you don't use the names they aren't much help.

// constant variables
#include <Stepper.h>

const int PartsensPin = 40;                   // Part in nest Sensor
const int SolenoidAPin = 30;                  // Solenoid A Pin Right Side
const int SolASensInPin = 2;                    // Solenoid A Sensor 1
const int SolASensOutPin = 3;                   // Solenoid A Sensor 2
const int SolenoidBPin = 4;                  // Solenoid B Pin Left Side
const int SolBSensInPin = 5;                    // Solenoid B Sensor 1
const int SolBSensOutPin = 6;                   // Solenoid B Sensor 2
const int DirMoter1 = 7;                       // motor 1 Dir pin Right
const int DirMoter2 = 8;                       // motor 2 Dir pin Right
const int DirMoter3 = 9;                       // motor 3 Dir pin Left
const int DirMoter4 = 10;                      // motor 4 Dir pin left
const int EjectionSolenoid = 11;            // ejection solinoid under nest
const int PressInPin = 44;                      // press start signal
const int PressOutPin = 13;                     // send finished or empty nest signal to press
const int StepPin1 = 14;
const int StepPin2 = 15;
const int StepPin3 = 16;
const int StepPin4 = 17;
const int RsFbs = 18;                        // Right Side Front Bump Switch for signalling arm back
const int RsBbs = 19;                        // Right Side Back Bump Switch for signaling arm is back
const int LsFbs = 20;                        // Left Side Front bump switch for signaling arm back
const int LsBbs = 21;                        // Left Side Back Bump Switch for signaling arm is back
int pd = 500;                             // Pulse Delay period
int pressState = 0;                       // Variable For reading press status
int prevpressState;
const int stepsPerRevolution = 5000;   // Stepps for revolution
// initialize the stepper library on pins 7 through 10 and 14 through 17:
Stepper myStepper(stepsPerRevolution, 14, 15, 16, 17);
bool powerOn = false;
bool partisin = false;
bool PowerForward = false;
bool BackItUpp = false;

boolean setdir = LOW;                     // Set Direction
void revmotor ()
{
  setdir = !setdir;
}
void setup()
{
  Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
  //setup to be adjusted 13 total
  // set the speed at 60rpm:
  pinMode(PressInPin, INPUT_PULLUP);             // Press signal input
  pinMode(PartsensPin, INPUT_PULLUP);         // part in nest sensor
  pinMode(SolASensInPin, INPUT_PULLUP);          // solenoid Sensor A In
  pinMode(SolASensOutPin, INPUT_PULLUP);         // solenoid Sensor A Out
  pinMode(SolBSensInPin, INPUT_PULLUP);          // Solenoid Sensor B In
  pinMode(SolBSensOutPin, INPUT_PULLUP);         // Solenoid sensor B Out
  pinMode(RsFbs, INPUT_PULLUP);               // Right Side Front Bumper Switch
  pinMode(RsBbs, INPUT_PULLUP);               // Right Side Back Bumper Switch
  pinMode(LsFbs, INPUT);               // Left Side Front Bump Switch
  pinMode(LsBbs, INPUT);               // Left Side Back Bump Switch

  pinMode(SolenoidAPin, OUTPUT);              // solonoid A is outputting
  pinMode(SolenoidBPin, OUTPUT);              // solonoid B is outputting
  pinMode(EjectionSolenoid, OUTPUT);          // Part ejection Solenoid
  pinMode(PressOutPin, OUTPUT);                  // Output to press

  pinMode(DirMoter1, OUTPUT);                    //  arm motor 1 LEFT
  pinMode(DirMoter2, OUTPUT);                    //  Saw motor LEFT
  pinMode(DirMoter3, OUTPUT);                    //  arm motor 2 RIGHT
  pinMode(DirMoter4, OUTPUT);                    //  arm motor RIGHT
  prevpressState = digitalRead(PressInPin);
#define SPD 2000
#define SLW_DWN_SPD 3000
}
//Homing sequence

void loop()
{
  // Lock In Original State Of each Sensor
  int partsensState = digitalRead(PartsensPin);
  int solAState = digitalRead(SolASensInPin);
  int solBState = digitalRead(SolBSensInPin);
  int pressState = digitalRead(PressInPin);
  int RsFbsstate = digitalRead(RsFbs);
  int LsFbsstate = digitalRead(LsFbs);
  int RsBbsstate = digitalRead(RsBbs);
  int LsBbsstate = digitalRead(LsBbs);
  // Press Input State :
  // powerswitch state change
  if ((digitalRead(PartsensPin) == HIGH) && (digitalRead(pressState)))
  {
    //Press On
    Serial.println("Press ON");
    delay(750);
    digitalWrite(SolenoidAPin, HIGH);      // Once the press says go, it waits till the part is sensed in the nest
    digitalWrite(SolenoidBPin, HIGH);
    Serial.println(" Part Is In Nest ");
    powerOn = true;
    partisin = true;
  }
  else
  {
    //press off
    Serial.println( "Press Off" );
    delay(500);
    digitalWrite(SolenoidAPin, LOW);
    digitalWrite(SolenoidBPin, LOW);
    powerOn = false;
    Serial.print(" No Part, back to start");    //the loop, until the parts in and press says go, code will not continue
  }
  delay(25);  // debounce

  //  cutting phase
  prevpressState = pressState;
  // only check sensors if powerOn is true
  if (partisin == true)
  {
    Serial.print( "A: "); Serial.print(PartsensPin);
    Serial.print( ", B: " ); Serial.print(solAState);
    Serial.print( ", C: " ); Serial.print(solBState);
    Serial.println();
    // if all the sensors say the clamps are down and part is in nest, start the saws
    // maybe try while to loop until conditions are met individually, use bool logic to hold it, or bool to create/access diffrent
begining:
      if ((digitalRead(RsFbs) == LOW) && (digitalRead(LsFbs) == LOW) && (digitalRead(RsBbs) == HIGH) && (digitalRead(LsBbs) == HIGH))
    {
      goto startloop;

    }
      else if ((digitalRead(RsFbs) == LOW) && (digitalRead(LsFbs) == LOW) && (digitalRead(RsBbs) == LOW) && (digitalRead(LsBbs) == LOW))
    {
      PowerForward = true;
      goto SelectACut;
    }
      else if ((digitalRead(RsFbs) == HIGH) && (digitalRead(LsFbs) == HIGH))
    {
      goto backup;
    }



startloop:
    myStepper.step(7200);
    Serial.println (" time to cutty");
    digitalWrite(DirMoter2, HIGH);            // set direction
    digitalWrite(DirMoter4, HIGH);
    digitalWrite(StepPin2, HIGH);
    digitalWrite(StepPin4, HIGH);
    Serial.println (" Start saws ");
    digitalWrite(StepPin1, HIGH);
    digitalWrite(StepPin3, HIGH);
    digitalWrite(DirMoter1, HIGH);                // start the cutting motion
    digitalWrite(DirMoter3, HIGH);
    Serial.println(" still cuttin ");
    goto begining;

backup:
    myStepper.step(3000);
    Serial.println("Time to reset");
    digitalWrite(StepPin2, setdir);
    digitalWrite(StepPin4, setdir);
    digitalWrite(DirMoter2, LOW);                // reverse the cutting motion
    digitalWrite(DirMoter4, LOW);
    digitalWrite(StepPin2, HIGH);           // Start the stepper Motor saws
    digitalWrite(StepPin4, HIGH);
    goto begining;

SelectACut:
    if ((digitalRead(DirMoter2) == HIGH) && (digitalRead(DirMoter4) == HIGH))
    {
      Serial.println(" Keep It Forward ");
      goto KeepItForward;
    }
    if ((digitalRead(DirMoter2) == LOW) && (digitalRead(DirMoter4) == LOW))
    {
      goto KeepBackingUp;
    }

KeepItForward:
    while ((digitalRead(RsFbs) == LOW) && (digitalRead(LsFbs) == LOW) && (digitalRead(RsBbs) == LOW) && (digitalRead(LsBbs) == LOW))
    {
      myStepper.step(7200);
      Serial.println (" time to cutty");
      digitalWrite(DirMoter2, HIGH);            // set direction
      digitalWrite(DirMoter4, HIGH);
      digitalWrite(StepPin2, HIGH);
      digitalWrite(StepPin4, HIGH);
      Serial.println (" Start saws ");
      digitalWrite(StepPin1, HIGH);
      digitalWrite(StepPin3, HIGH);
      digitalWrite(DirMoter1, HIGH);                // start the cutting motion
      digitalWrite(DirMoter3, HIGH);
      Serial.println(" still cuttin ");
    }
      delay(2500);
      PowerForward = false;
      goto begining;
    

KeepBackingUp:
    myStepper.step(3000);
    Serial.println("Keep going Back");
    digitalWrite(StepPin2, setdir);
    digitalWrite(StepPin4, setdir);
    digitalWrite(DirMoter2, LOW);                // reverse the cutting motion
    digitalWrite(DirMoter4, LOW);
    digitalWrite(StepPin2, HIGH);           // Start the stepper Motor saws
    digitalWrite(StepPin4, HIGH);
    goto begining;
  }
}

startloop:Uh-oh

I'm having an issue where the code is now getting stuck in the "startloop:" Like was quoted, any suggestions?

jefhod:
any suggestions?

Get rid of the gotos.

jefhod:
any suggestions?

There is something VERY wrong with your stepper handling. The "Stepper" library is only for a 4-coil stepper where each pin drives a coil. You appear to be using four Step and Direction stepper drivers that have two pins each. Which is it?

// initialize the stepper library on pins 7 through 10 and 14 through 17:
Stepper myStepper(stepsPerRevolution, 14, 15, 16, 17);


    myStepper.step(7200);

This is going to send 7200 pulses to the four Step pins in sequence. All four steppers will move in the same number of steps (7200/4) and a direction that depends on the state of the Direction pin of each driver. That is a VERY unusual way to move four steppers, especially when you don't set the Direction outputs until you finish the Step pulses.