Issue with buttons combining two sketches

Hello all. I have two working sketches that I am trying to combine into one sketch. The first one is simple:

#include <Button.h>
#include <AFMotor.h> //Connect a dc motor to motor port #1 (M1)

Button Ttable = Button(24,PULLUP); //Ttable button
int TtableSwitch = 23; //declares the table switch on pin 23
int LED = 13; //LED on pin 13
AF_DCMotor TtableMotor(1, MOTOR12_64KHZ); //attaches table dc motor to port 1

void setup() {

   pinMode(TtableSwitch, INPUT_PULLUP);  //delcares table switch as input PULLUP inverts logic
   TtableMotor.setSpeed(65);  //

  Serial.begin(9600);// initialize the serial port:
}

void loop() {
  Serial.print("Button State: ");
  Serial.println(digitalRead(TtableSwitch)); // Read the pin and display the value
   delay(250);
  pinMode(LED,OUTPUT); //intialize the LED pin as an output
  
  if (Ttable.isPressed()) //check if the Ttable is pressed
  {
  digitalWrite(13,HIGH); //turns on LED
  
  TtableMotor.run(FORWARD);
  delay(750);
  
  while(digitalRead(TtableSwitch)==LOW)
  { //waiting for switch
  }
  TtableMotor.run(RELEASE); //releases motor
  
  digitalWrite(13,LOW); //turns LED off
 } 
}

When I try to splice this code into another working sketch, it ignores this code. Here is the sketch where I tried to combine the two.

//fire button works, LEDs work, pot delays work
//Ttable button does not work

#include <AFMotor.h>
#include <Button.h>
#include <Servo.h>
#include <Bounce.h>

/*-----( Declare Constants )-----*/
#define RELAY_ON 0
#define RELAY_OFF 1
/*-----( Declare Variables )-----*/

Servo pinch;//creates a servo called pinch
int hom = 0;//variable for pinch servo home
int pnch = 90;//pinch servo storke
int ledPin =  13; //LED pin
int hor = 49; //choose the output pin for the horizontal relay
int ver = 47; //choose the output pin for the vertical relay
int inputProx = 4; //choose the input pin for proximity switch
int horextled = 26; //output for horizontal extend LED
int horretled = 28; //output for horizontal retract LED
int verextled = 30; //output for vertical extend LED
int verretled = 32; //output for vertical retract LED
int hpotPin = A0; //input pin (Analog 0) for the horizontal potentiometer
int hpotVal = 0; //variable for reading the horizontal poteniometer
int vpotPin = A1; //input pin (Analog 1) for the vertical potentiometer
int vpotVal = 0; //variable for reading the vertical poteniometer
int pinchPin = A2; //input pin (Analog 2) for the pinch potentiometer
int pinchVal = 0; //variable for reading the pinch poteniometer
int Fire = 22; //Fire button pin
int FireState = 0; //store Fire button value
Button Ttable = Button(24,PULLUP); //Ttable button pin
int TtableVal = 0; //variable for reading table switch
int TtableSwitch = 23; //declares the table switch pin
AF_DCMotor TtableMotor(1, MOTOR12_64KHZ); //attaches table dc motor to port 1

// Instantiate a Bounce object with a 500 millisecond debounce time
Bounce bouncer = Bounce( Fire,500 );

void setup()    /****** SETUP: RUNS ONCE ******/
{
  Serial.begin(9600); // set up Serial library at 9600 bps
  
//-------( Initialize Pins so relays are inactive at reset)----
  digitalWrite(hor, RELAY_OFF);
  digitalWrite(ver, RELAY_OFF);
  
//---( THEN set pins as outputs )----
  pinch.attach(9); //attaches pinch servo using Adafruit Motor Shield servo2
  pinch.write(hom); //returns pinch servo home **fixes servo twitch
  pinMode(Fire, INPUT); //declare pushbutton as input
  pinMode(inputProx, INPUT); //declare proximity switch as input
  pinMode(hor, OUTPUT); //declare hor pin as output
  pinMode(ver, OUTPUT); //declare ver pin as output
  pinMode(horextled, OUTPUT); //declare horizontal extend LED
  pinMode(horretled, OUTPUT); //declare horizontal retract LED
  pinMode(verextled, OUTPUT); //declare veritcal extend LED
  pinMode(verretled, OUTPUT); //declare vertical retract LED
  pinMode(TtableSwitch, INPUT_PULLUP); //delcares table switch as input PULLUP inverts logic
  TtableMotor.setSpeed(65); //
}
void loop()
{
  Serial.print("Ttable Button: ");
  Serial.println(digitalRead(24)); // Read the pin and display the value
  delay(200);
  // Update the debouncer
  bouncer.update ( );
 
 // Get the update value
 int value = bouncer.read();
 
  pinch.write(hom); //returns pinch servo home  
  digitalWrite(hor,RELAY_OFF); //turns horizontal relay off
  digitalWrite(ver,RELAY_OFF); //turns vertical relay off
  digitalWrite(horretled, HIGH); //lights horizontal retract LED
  digitalWrite(verretled, HIGH); //lights vertical retract LED
  FireState = digitalRead(Fire); //reads Fire button
  
          //INDEX SPONGE WORM TURN TABLE
  if (Ttable.isPressed()){  //check if the Ttable button is pressed
    digitalWrite(13,HIGH); //turns on LED
    TtableMotor.run(FORWARD); //starts dc motor
     delay(750); //lets table turn to release switch
  while(digitalRead(TtableSwitch)==LOW)
  { //waiting for switch
  }
  TtableMotor.run(RELEASE); //releases motor
  digitalWrite(13,LOW); //turns LED off
  }
  else if (FireState == HIGH) //check if the input is HIGH  
  {
   digitalWrite(horretled, LOW);//turn off horizontal retract LED
   digitalWrite(horextled, HIGH);//turns on horizontal extend LED
   digitalWrite(hor,RELAY_ON); //turns horizontal relay on
   int hpotVoltz = analogRead(A0);
   float hvoltage = hpotVoltz * (5/1023.0);
   Serial.print("Hpot ");
   Serial.println(hvoltage);
   hpotVal = analogRead(hpotPin);//reads the value from the horizontal poteniometer
    delay(hpotVal*5); //reads Horizontal potentiometer
   digitalWrite(hor,RELAY_OFF); //turns horizontal relay off
    //delay(350);
   hpotVal = 0;//resets variable for reading the horizontal poteniometer
   
   //wait for a proximity sensor to detect a block has returned to it's position
      //while (digitalRead(inputProx) == HIGH)
      {
  //waiting for return
      }
   digitalWrite(horextled, LOW);//turns off horizontal extend LED
   digitalWrite(horretled, HIGH);//turns on horizontal retract LED
   digitalWrite(verretled, LOW);//turns off vertical retract LED
   digitalWrite(verextled, HIGH);//turn on vertical extend LED
   digitalWrite(ver,RELAY_ON); //turns vertical relay on
   int vpotVoltz = analogRead(A1);
   float vvoltage = vpotVoltz * (5/1023.0);
   Serial.print("Vpot ");
   Serial.println(vvoltage);
   vpotVal = analogRead(vpotPin);//reads the value from the Vertical poteniometer
    delay(vpotVal*5); //reads Vertical potentiometer
   digitalWrite(ver,RELAY_OFF); //turns vertical relay off
    //delay(350);
   vpotVal = 0;//resets variable for reading the horizontal poteniometer
   digitalWrite(verextled, LOW);//turns off vertical exttend LED
    delay(150);
    
   int ppotVoltz = analogRead(A2);
   float pvoltage = ppotVoltz * (5/1023.0);
   Serial.print("Ppot ");
   Serial.println(pvoltage);
   pinch.write(pnch);//pinches tube
   pinchVal = analogRead(pinchPin);//reads the value from the pinch potentiometer
    delay(pinchVal*2);//reads Pinch potentiometer
   pinch.write(hom);//returns pinch servo home
    //delay(250);//waits for pinch servo to get home
   pinchVal = 0;//resets variable for reading the Pinch poteniometer
    
  }
 }

I set up the Serial Monitor to watch the Ttable button and it streams 1, when pushed it hesitates but does not display anything. If I hold the Ttable button down it will stream 0 until I let go of it, then it streams 1 again. So this means it’s reading the Ttable button correct? When I monitor the Fire button, it behaves as it should.

  pinMode(LED,OUTPUT); //intialize the LED pin as an output

Why are you doing this in loo()?

  digitalWrite(13,HIGH); //turns on LED

What happened to the nice name?

  Serial.println(digitalRead(24)); // Read the pin and display the value

What happened to the nice name?

Why are you now reading from pin 24, when you were reading from pin 23?

This demo about merging sketches may help.

...R

Programs using "delay" only work if it is doing one thing at a time.
Look up Arduino example "Blink without Delay" for example on how to avoid using delay.
Otherwise, the whole program is stopped for the delay and therefore, nothing works through this period.

Thanks for the response guys. The pinMode(LED,OUTPUT); in void loop() instead of void setup() was me going to fast and not paying attention, i fixed it thanks. Same deal with digitalWrite(13,HIGH);, thinking LED wrote 13. The Serial.println(digitalRead(24)); was only way I could get the serial monitor to print it's state. If I put serial.println(digitalRead(Ttable)); I get an error. As far pin 23 or 24 goes, the Ttable button is pin 24 and the TtableSwitch is pin 23. I was using the serial monitor to check if the code was reading the state of each pin. The serial monitor is reading the Ttable button (24), it streams 1 while sitting idle. If I push the button there is a pause but it does not change the state to 0. If I hold the Ttable button (24) down it will stream 0 until I release it, then it streams 1 again.

jndipworm:
If I push the button there is a pause but it does not change the state to 0. If I hold the Ttable button (24) down it will stream 0 until I release it, then it streams 1 again.

I'm not sure from this if you still have a problem. If you have, please post your latest code and ask a specific question.

...R

There is no new code to post. All of the critiques so far have been about the first working code I am trying to splice into an existing sketch. The issue is in the second code I posted, the Ttable button on pin 24 is ignored. Here is the code I added.

         //INDEX SPONGE WORM TURN TABLE
  if (Ttable.isPressed()){  //check if the Ttable button is pressed
    digitalWrite(LED,HIGH); //turns on LED
    TtableMotor.run(FORWARD); //starts dc motor
     delay(750); //lets table turn to release switch
  while(digitalRead(TtableSwitch)==LOW)
  { //waiting for switch
  }
  TtableMotor.run(RELEASE); //releases motor
  digitalWrite(LED,LOW); //turns LED off
  }

I think I have something missing in void setup() or above in my declarations. Been looking at this for a week trying to sort it out.

All of the critiques so far have been about the first working code

No. Some of the comments have addressed the second code.

Some of the comments you have ignored, like using names for the pins, not numbers.

If you are going to ignore our advice, why should we continue trying to help?

I apologize. My frustration is getting the better of me. I will clean up the code and look more carefully. I know I need to be more thorough now. As my code gets more complicated I need to slow down and read every line. Once again I apologize.

I think that you'll find that the code is easier to read if you use names, instead of numbers. I think you'll also find it easier to read if you put every { and every} on new lines, and properly indent the code:

  if (Ttable.isPressed())
  {  //check if the Ttable button is pressed
    digitalWrite(LED,HIGH); //turns on LED
    TtableMotor.run(FORWARD); //starts dc motor
    delay(750); //lets table turn to release switch
    while(digitalRead(TtableSwitch)==LOW)
    { //waiting for switch
    }
    TtableMotor.run(RELEASE); //releases motor
    digitalWrite(LED,LOW); //turns LED off
  }

Then, of course, the placement of comments sucks. If the comment is important, it should go before the code that needs commenting.

When you have made whatever changes you want to your code post it all again in your next post so we can all start over from that point without having to refer back to several earlier posts. And describe (again if necessary) what you want it to do and what it actually does.

...R

Ok, I cleaned up the variable names, no numbers. I tried to clean up the indents, not sure that’s 100%. The section of code that does not work is //INDEX SPONGE WORM TURN TABLE. This section of the code is ignored, the turn table (Ttable) does not rotate. Everything after this section works.

//fire button works, LEDs work, pot delays work
//Ttable button does not work

#include <AFMotor.h>
#include <Button.h>
#include <Servo.h>
#include <Bounce.h>

/*-----( Declare Constants )-----*/
#define RELAY_ON 0
#define RELAY_OFF 1
/*-----( Declare Variables )-----*/

Servo pinch; //creates a servo called pinch
int hom = 0; //variable for pinch servo home
int pnch = 90; //pinch servo storke
int LED = 13; //LED pin
int hor = 49; //choose the output pin for the horizontal relay
int ver = 47; //choose the output pin for the vertical relay
int inputProx = 4; //choose the input pin for proximity switch
int horextled = 26; //output for horizontal extend LED
int horretled = 28; //output for horizontal retract LED
int verextled = 30; //output for vertical extend LED
int verretled = 32; //output for vertical retract LED
int hpotPin = A0; //input pin (Analog 0) for the horizontal potentiometer
int hpotVal = 0; //variable for reading the horizontal poteniometer
int vpotPin = A1; //input pin (Analog 1) for the vertical potentiometer
int vpotVal = 0; //variable for reading the vertical poteniometer
int pinchPin = A2; //input pin (Analog 2) for the pinch potentiometer
int pinchVal = 0; //variable for reading the pinch poteniometer
int Fire = 22; //Fire button pin
int FireState = 0; //store Fire button value
Button Ttable = Button(24,PULLUP); //Ttable button pin
int TtableVal = 0; //variable for reading table switch
int TtableSwitch = 23; //declares the table switch pin
AF_DCMotor TtableMotor(1, MOTOR12_64KHZ); //attaches table dc motor to port 1

// Instantiate a Bounce object with a 500 millisecond debounce time
Bounce bouncer = Bounce(Fire,500);

void setup()    
{
  Serial.begin(9600);
  
//-------( Initialize Pins so relays are inactive at reset)----
  digitalWrite(hor, RELAY_OFF);
  digitalWrite(ver, RELAY_OFF);
  
//---( THEN set pins as outputs )----
  pinch.attach(9); //attaches pinch servo using Adafruit Motor Shield servo2
  pinch.write(hom); //returns pinch servo home **fixes servo twitch
  pinMode(LED,OUTPUT); //declare LED as output
  pinMode(Fire, INPUT); //declare pushbutton as input
  pinMode(inputProx, INPUT); //declare proximity switch as input
  pinMode(hor, OUTPUT); //declare hor pin as output
  pinMode(ver, OUTPUT); //declare ver pin as output
  pinMode(horextled, OUTPUT); //declare horizontal extend LED
  pinMode(horretled, OUTPUT); //declare horizontal retract LED
  pinMode(verextled, OUTPUT); //declare veritcal extend LED
  pinMode(verretled, OUTPUT); //declare vertical retract LED
  pinMode(TtableSwitch, INPUT_PULLUP); //delcares table switch as input PULLUP inverts logic
  TtableMotor.setSpeed(65);
}
void loop()
{
  Serial.print("Ttable Button: ");
  Serial.println(digitalRead(Ttable)); // Read the pin and display the value
  delay(200);
  // Update the debouncer
  bouncer.update( );
 
 // Get the update value
 int value = bouncer.read();
 
  pinch.write(hom); //returns pinch servo home  
  digitalWrite(hor,RELAY_OFF); //turns horizontal relay off
  digitalWrite(ver,RELAY_OFF); //turns vertical relay off
  digitalWrite(horretled, HIGH); //lights horizontal retract LED
  digitalWrite(verretled, HIGH); //lights vertical retract LED
  FireState = digitalRead(Fire); //reads Fire button
  
          //INDEX SPONGE WORM TURN TABLE
  if (Ttable.isPressed())
  {  //check if the Ttable button is pressed
    digitalWrite(LED,HIGH);
    TtableMotor.run(FORWARD); //starts dc motor
    delay(750); //lets table turn to release switch
    while(digitalRead(TtableSwitch)==LOW)
    { //waiting for switch
    }
    TtableMotor.run(RELEASE); //releases motor
    digitalWrite(LED,LOW);
  }
  
  else if (FireState == HIGH) //check if the input is HIGH  
  
  {
   digitalWrite(horretled, LOW);//turn off horizontal retract LED
   digitalWrite(horextled, HIGH);//turns on horizontal extend LED
   digitalWrite(hor,RELAY_ON); //turns horizontal relay on
   int hpotVoltz = analogRead(A0);
   float hvoltage = hpotVoltz * (5/1023.0);
   Serial.print("Hpot ");
   Serial.println(hvoltage);
   hpotVal = analogRead(hpotPin);//reads the value from the horizontal poteniometer
   delay(hpotVal*5); //reads Horizontal potentiometer
   digitalWrite(hor,RELAY_OFF); //turns horizontal relay off
   //delay(350);
   hpotVal = 0;//resets variable for reading the horizontal poteniometer
   
   //wait for a proximity sensor to detect a block has returned to it's position
      //while (digitalRead(inputProx) == HIGH)
  {
    //waiting for return
  }
   digitalWrite(horextled, LOW);//turns off horizontal extend LED
   digitalWrite(horretled, HIGH);//turns on horizontal retract LED
   digitalWrite(verretled, LOW);//turns off vertical retract LED
   digitalWrite(verextled, HIGH);//turn on vertical extend LED
   digitalWrite(ver,RELAY_ON); //turns vertical relay on
   int vpotVoltz = analogRead(A1);
   float vvoltage = vpotVoltz * (5/1023.0);
   Serial.print("Vpot ");
   Serial.println(vvoltage);
   vpotVal = analogRead(vpotPin);//reads the value from the Vertical poteniometer
   delay(vpotVal*5); //reads Vertical potentiometer
   digitalWrite(ver,RELAY_OFF); //turns vertical relay off
   //delay(350);
   vpotVal = 0;//resets variable for reading the horizontal poteniometer
   digitalWrite(verextled, LOW);//turns off vertical exttend LED
   delay(150);
    
   int ppotVoltz = analogRead(A2);
   float pvoltage = ppotVoltz * (5/1023.0);
   Serial.print("Ppot ");
   Serial.println(pvoltage);
   pinch.write(pnch);//pinches tube
   pinchVal = analogRead(pinchPin);//reads the value from the pinch potentiometer
   delay(pinchVal*2);//reads Pinch potentiometer
   pinch.write(hom);//returns pinch servo home
   //delay(250);//waits for pinch servo to get home
   pinchVal = 0;//resets variable for reading the Pinch poteniometer
    
  }
 }
Button Ttable = Button(24,PULLUP); //Ttable button pin
int TtableVal = 0; //variable for reading table switch
int TtableSwitch = 23; //declares the table switch pin

I STILL don't know which pin the turntable switch is attached to.

The first comment is wrong. The code has nothing to do with defining a pin.

  Serial.print("Ttable Button: ");
  Serial.println(digitalRead(Ttable)); // Read the pin and display the value

Rubbish. Ttable is a Button instance. It is NOT a pin number.

  if (Ttable.isPressed())
  {  //check if the Ttable button is pressed
    digitalWrite(LED,HIGH);
    TtableMotor.run(FORWARD); //starts dc motor
    delay(750); //lets table turn to release switch
    while(digitalRead(TtableSwitch)==LOW)
    { //waiting for switch
    }

Are you going to use the Button instance, or not? Do not switch back and forth.

PaulS, there is a button I called Ttable on pin 24 that starts a dc motor turning a rotary table. I have a switch I called TtableSwitch on pin 23 that stops the rotary table from turning. This code works in this sketch:

#include <Button.h>
#include <AFMotor.h> //Connect a dc motor to motor port #1 (M1)

Button Ttable = Button(24,PULLUP); //Ttable button
int TtableSwitch = 23; //declares the table switch on pin 23
int LED = 13; //LED on pin 13
AF_DCMotor TtableMotor(1, MOTOR12_64KHZ); //attaches table dc motor to port 1

void setup() 
{
   pinMode(LED,OUTPUT); //intialize the LED pin as an output
   pinMode(TtableSwitch, INPUT_PULLUP); //delcares table switch as input PULLUP inverts logic
   TtableMotor.setSpeed(65);
}

void loop() {
    
  if (Ttable.isPressed()) //check if the Ttable is pressed
  {
  digitalWrite(LED,HIGH);
  TtableMotor.run(FORWARD);
  delay(750);
  while(digitalRead(TtableSwitch)==LOW)
  { //waiting for switch
  }
  TtableMotor.run(RELEASE); //releases motor
  digitalWrite(LED,LOW);
 } 
}

I am trying to add this code. As far as the Serial.println you pointed out, when I change digitalRead(Ttable) to digitalRead(24) it will read the state of the button that starts the turntable rotating. I was trying to replace the pin number with the pin name like you asked me to do. I will be the first to admit I have a LONG way to go. I am trying…

PaulS, there is a button I called Ttable on pin 24 that starts a dc motor turning a rotary table. I have a switch I called TtableSwitch on pin 23 that stops the rotary table from turning.

Then, I would expect the names to reflect the purpose of the pin. For instance, tTableStartPin and tTableStopPin.

There is no reason that I can see to have Button instances for some switch pins but not others. Consistency is a good thing.

As far as the Serial.println you pointed out, when I change digitalRead(Ttable) to digitalRead(24) it will read the state of the button that starts the turntable rotating.

Then, it should be digitalRead(23). This is why good names are SO important.

I changed the names to be more descriptive. I removed the Serial.println because it is not the reason I posted this code. My code has lots of issues I will get better at. Here is the new code and still has the same issue, it is not reacting to the tTableStartPin button when it is pressed.

//fireStartPin button works, LEDs work, pot delays work
//tTableStartPin button does not work

#include <AFMotor.h>
#include <Button.h>
#include <Servo.h>
#include <Bounce.h>

/*-----( Declare Constants )-----*/
#define RELAY_ON 0
#define RELAY_OFF 1
/*-----( Declare Variables )-----*/

Servo pinch; //creates a servo called pinch
int hom = 0; //variable for pinch servo home
int pnch = 90; //pinch servo storke
int LED = 13; //LED pin
int hor = 49; //choose the output pin for the horizontal relay
int ver = 47; //choose the output pin for the vertical relay
int Prox = 4; //choose the input pin for proximity switch
int horextled = 26; //output for horizontal extend LED
int horretled = 28; //output for horizontal retract LED
int verextled = 30; //output for vertical extend LED
int verretled = 32; //output for vertical retract LED
int hpotPin = A0; //input pin (Analog 0) for the horizontal potentiometer
int hpotVal = 0; //variable for reading the horizontal poteniometer
int vpotPin = A1; //input pin (Analog 1) for the vertical potentiometer
int vpotVal = 0; //variable for reading the vertical poteniometer
int pinchPin = A2; //input pin (Analog 2) for the pinch potentiometer
int pinchVal = 0; //variable for reading the pinch poteniometer
int fireStartPin = 22; //Fire button pin
int fireStartPinState = 0; //store fireStartPin button value
Button tTableStartPin = Button(24,PULLUP); //tTableStartPin button pin
int tTableStopPin = 23; //declares the tTableStopPin
AF_DCMotor TtableMotor(1, MOTOR12_64KHZ); //attaches turntable dc motor to port 1

// Instantiate a Bounce object with a 500 millisecond debounce time
Bounce bouncer = Bounce(fireStartPin,500);

void setup()    
{
  Serial.begin(9600);
  
//-------( Initialize Pins so relays are inactive at reset)----
  digitalWrite(hor, RELAY_OFF);
  digitalWrite(ver, RELAY_OFF);
  
//---( THEN set pins as outputs )----
  pinch.attach(9); //attaches pinch servo using Adafruit Motor Shield servo2
  pinch.write(hom); //returns pinch servo home **fixes servo twitch
  pinMode(LED,OUTPUT); //declare LED as output
  pinMode(fireStartPin,INPUT); //declare pushbutton as input
  pinMode(Prox,INPUT); //declare proximity switch as input
  pinMode(hor,OUTPUT); //declare hor pin as output
  pinMode(ver,OUTPUT); //declare ver pin as output
  pinMode(horextled,OUTPUT); //declare horizontal extend LED
  pinMode(horretled,OUTPUT); //declare horizontal retract LED
  pinMode(verextled,OUTPUT); //declare veritcal extend LED
  pinMode(verretled,OUTPUT); //declare vertical retract LED
  pinMode(tTableStopPin,INPUT_PULLUP); //delcares table switch as input PULLUP inverts logic
  TtableMotor.setSpeed(65);
}
void loop()
{
  // Update the debouncer
  bouncer.update( );
  
  // Get the update value
  int value = bouncer.read();
  
  pinch.write(hom); //returns pinch servo home  
  digitalWrite(hor,RELAY_OFF); //turns horizontal relay off
  digitalWrite(ver,RELAY_OFF); //turns vertical relay off
  digitalWrite(horretled, HIGH); //lights horizontal retract LED
  digitalWrite(verretled, HIGH); //lights vertical retract LED
  fireStartPinState = digitalRead(fireStartPin); //reads fireStartPin button
  
          //INDEX SPONGE WORM TURN TABLE
  if (tTableStartPin.isPressed())
  {  //check if the tTableStartPin button is pressed
    digitalWrite(LED,HIGH);
    TtableMotor.run(FORWARD); //starts dc motor
    delay(750); //lets table turn to release switch
    while(digitalRead(tTableStopPin)==LOW)
    { //waiting for switch
    }
    TtableMotor.run(RELEASE); //releases motor
    digitalWrite(LED,LOW);
  }
  
  else if (fireStartPinState == HIGH) //check if the input is HIGH  
  
  {
   digitalWrite(horretled, LOW);//turn off horizontal retract LED
   digitalWrite(horextled, HIGH);//turns on horizontal extend LED
   digitalWrite(hor,RELAY_ON); //turns horizontal relay on
   int hpotVoltz = analogRead(A0);
   float hvoltage = hpotVoltz * (5/1023.0);
   Serial.print("Hpot ");
   Serial.println(hvoltage);
   hpotVal = analogRead(hpotPin);//reads the value from the horizontal poteniometer
   delay(hpotVal*5); //reads Horizontal potentiometer
   digitalWrite(hor,RELAY_OFF); //turns horizontal relay off
   //delay(350);
   hpotVal = 0;//resets variable for reading the horizontal poteniometer
   
   //wait for a proximity sensor to detect a block has returned to it's position
      //while (digitalRead(inputProx) == HIGH)
  {
    //waiting for return
  }
   digitalWrite(horextled, LOW);//turns off horizontal extend LED
   digitalWrite(horretled, HIGH);//turns on horizontal retract LED
   digitalWrite(verretled, LOW);//turns off vertical retract LED
   digitalWrite(verextled, HIGH);//turn on vertical extend LED
   digitalWrite(ver,RELAY_ON); //turns vertical relay on
   int vpotVoltz = analogRead(A1);
   float vvoltage = vpotVoltz * (5/1023.0);
   Serial.print("Vpot ");
   Serial.println(vvoltage);
   vpotVal = analogRead(vpotPin);//reads the value from the Vertical poteniometer
   delay(vpotVal*5); //reads Vertical potentiometer
   digitalWrite(ver,RELAY_OFF); //turns vertical relay off
   //delay(350);
   vpotVal = 0;//resets variable for reading the horizontal poteniometer
   digitalWrite(verextled, LOW);//turns off vertical exttend LED
   delay(150);
    
   int ppotVoltz = analogRead(A2);
   float pvoltage = ppotVoltz * (5/1023.0);
   Serial.print("Ppot ");
   Serial.println(pvoltage);
   pinch.write(pnch);//pinches tube
   pinchVal = analogRead(pinchPin);//reads the value from the pinch potentiometer
   delay(pinchVal*2);//reads Pinch potentiometer
   pinch.write(hom);//returns pinch servo home
   //delay(250);//waits for pinch servo to get home
   pinchVal = 0;//resets variable for reading the Pinch poteniometer
    
  }
 }
Button tTableStartPin = Button(24,PULLUP); //tTableStartPin button pin

The Button instance is NOT a pin.

You really need to ditch the Button class AND the Bounce class. You refuse to use ONE method to read the pins that those objects are associated with.

PaulS, it's not that I refuse, I don't know what you're talking about. I don't know what you mean when you say "The Button instance is NOT a pin." All the examples I've seen for Button show code like that. I thought I was assigning a button called tTableStartPin to pin 24. You say I need to ditch the Button class AND the Bounce class. How do I read the two buttons? I'm not trying to argue, I'm more confused now then ever.

I think the problem is that you are using a Button library which I certainly know nothing about. Any time I want to read a button I just use simple code like btnAstate = digitalRead(btnApin);

One of the downsides of using a library is that it makes it harder to get help when you don't know exactly how to use it.

I am not going to teach myself how the Button library works just so I can figure out your problem. But if you wish to revise your code and not use the library I will be happy to help.

...R

That sounds good. Let me work on some of what PaulS wanted me to do. I will clean up the Button and Bounce issue and just go with one not both. I think it doesn't help that I have new sketch that uses Button.h and works very well and added it to an older sketch that uses Bounce.h. I didn't think it would matter.