Button not activating function with attachInterrupt()

Hi everyone, here is a script I'm currently running for a project I have created:

// Include statements with all header files necessary
#include <avr/pgmspace.h>
#include <Adafruit_MAX31865.h>
// ---------- CONSTANTS ---------- //

// High and Low PSI Values
const float PSI_LOW = 21;
const float PSI_HIGH = 121;

// ---------- PROFILES ---------- //

// STANDARD PROFILE
#define Standard_Shifts 12
#define Standard_Times 12
const int Standard_Shift[Standard_Shifts] = {1,1,1,1,1,1,0,0,0,0,0,0};
const float Standard_Time[Standard_Times] = {1,1,1,1,1,1,1,1,1,1,1,1};

// ENDURANCE PROFILE
#define Endurance_Shifts 344
#define Endurance_Times 344
const int Endurance_Shift[] = {1,0,1,0,1,0,1,0,1,1,0,1,1,0,0,1,1,0,0,1,0,1,0,1,0,1,1,0,1,1,0,0,1,1,0,0,1,\
0,1,0,1,0,1,1,0,1,0,0,1,1,1,0,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,1,0,0,1,1,1,0,0,1,0,1,1,0,0,1,0,1,0,1,0,\
1,0,1,1,0,0,1,0,1,1,0,0,1,1,1,0,0,0,1,1,0,0,1,0,1,0,1,0,1,0,1,1,0,1,1,0,0,1,1,0,0,1,0,1,1,0,0,1,0,1,0,1,0,1\
,0,1,1,1,0,0,1,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,1,0,1,1,0,0,0,1,1,1,0,0,1,1,0,1,0,0,1,0,1,0,1,0,1,1,1,0,0,0,1,1\
,1,0,0,0,1,1,0,0,1,0,1,0,1,0,1,1,0,1,1,0,0,0,1,1,1,0,0,0,1,1,0,0,1,0,1,0,1,0,1,0,1,0,1,1,1,0,0,1,1,0,0,1,1,0,\
0,1,0,1,0,1,0,1,1,0,1,1,0,0,1,1,0,0,1,1,0,1,0,0,1,0,1,0,1,0,1,0,1,0,1,1,1,0,0,1,1,0,0,0,1,1,0,0,1,0,1,0,1,0,1\
,0,1,0,1,1,0,0,1,1,1,0,0,0,1,1,0,1,0,1,0,1,0,0,1,0,1,1,0,0,1,1,0,0,1,1,1,0};
const float Endurance_Time[] = {1.2,2.9,2.35,1.6,2.35,0.7,1.75,1.25,2.05,4.3,1.4,2.3,1.6,0.75,0.35,5.6,1.6,2.25\
,1.05,1.55,2.85,1.85,0.7,3.65,0.75,4.85,1.05,0.95,4.75,1.4,1.25,0.25,5.4,1.55,1.9,0.15,12.05,6.05,4.45,0.8,11.6,\
0.7,8.4,3.85,0.95,5.3,2.35,0.8,4.05,0.9,1.65,1.35,0.25,11.9,2.25,2.35,2.1,3.2,0.85,2.95,1.3,7.25,1.0,6.9,2.45,1.9,\
1.7,2.3,1.1,1.0,1.35,3.1,0.7,3.05,1.05,1.65,1.25,0.35,0.5,0.65,10.75,1.3,0.6,0.6,2.45,1.0,7.25,1.6,7.7,0.85,6.55,2.55\
,2.1,1.1,0.5,0.65,1.85,0.85,0.95,1.1,2.1,0.5,4.4,1.15,1.6,1.5,0.2,0.75,10.15,1.55,1.3,4.7,3.1,0.8,2.55,1.25,7.8,0.95,7.85\
,1.65,2.15,0.95,0.9,4.15,1.55,1.4,0.85,3.1,1.9,2.6,0.05,0.5,0.6,9.5,1.5,1.4,4.6,6.3,1.35,8.05,1.05,7.0,2.6,2.35,1.65,2.85\
,1.8,1.65,0.75,0.95,3.8,2.35,1.6,0.45,1.1,9.9,6.35,3.05,0.8,2.9,1.2,7.8,0.75,6.7,1.85,2.85,1.1,0.4,3.65,1.85,1.25,0.5\
,0.85,3.05,1.25,1.55,1.6,0.2,11.1,2.35,0.75,3.1,1.1,0.4,6.0,1.5,15.95,1.6,3.1,1.6,1.7,2.55,1.65,0.8,0.35,0.4,3.55,1.25\
,1.55,1.8,0.1,0.9,10.65,1.05,1.1,3.95,6.6,1.5,7.7,1.25,6.35,2.9,1.75,1.2,0.85,4.7,1.65,1.85,0.3,0.2,2.5,1.0,1.45,1.85,\
0.15,0.85,6.7,5.35,1.15,4.25,2.25,1.3,2.45,1.1,4.0,4.8,1.4,2.0,4.15,2.15,1.65,5.85,1.65,1.15,0.6,4.25,1.45,1.95,0.25,5.8\
,7.25,1.35,4.35,3.0,0.8,2.7,1.1,15.9,1.6,2.5,0.95,0.7,3.8,1.95,1.05,0.3,4.7,1.55,2.1,1.05,9.55,2.25,0.9,2.7,0.6,0.3,3.45\
,0.95,2.05,1.6,3.65,3.3,1.15,1.45,6.1,3.05,2.2,5.35,1.9,1.2,0.8,4.3,1.7,1.6,0.1,3.7,6.4,1.95,1.4,3.75,3.85,1.0,2.5,0.9,8.1\
,0.75,7.05,1.3,3.05,1.55,3.7,1.45,2.3,1.05,3.3,1.05,1.7,1.35,0.25,1.9,9.75,1.15,1.05,2.85,0.8,3.75,0.55,2.0,1.4,0.4,7.3,1.0\
,6.9,4.4,1.25,2.85,1.3,0.95,2.55,0.45,3.5,1.0,1.5,1.65};


// PROFILE 3 (OOPS ALL UPSHIFTS)
#define Profile3_Shifts 600
#define Profile3_Times 600
const int Profile3_Shift[] = {1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
                             0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
                             0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
                             0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
                             0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\
                             0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
const float Profile3_Time[] = {0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,\
                             0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,\
                             0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,
                             0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,\
                             0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,\
                             0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75,0.75};

// PROFILE 4
#define Profile4_Shifts 6
#define Profile4_Times 6
const int Profile4_Shift[] = {1,1,1,0,0,0};
const float Profile4_Time[] = {1,1,1,1,1,1};

// ---------- DEFINING VARIABLES AND PIN LOCATIONS ---------- //

// Defines where sensors are located
const int pressureSensor1 = A0;
const int pressureSensor2 = A5;

const int LVDTsensor = A7;

// Defines the pins that the upshift and downshift relays are attached to
const int upShiftPin = 3;
const int downShiftPin = 4;

// Defines the pins that the limit switches are attached to

const int upShiftLimitSwitchPin = 5;
const int downShiftLimitSwitchPin = 6;

// Define where the buttons are
const int upShiftButton = 35;
const int downShiftButton = 36;


const int CS_tank = 43;
const int CS_solenoid = 42;
const int DI_pin = 44;
const int DO_pin = 45;
const int CLK_pin = 47;

#define RREF 430.0
#define RNOMINAL 100.0

// ------- DEFINE SENSORS ------- //

Adafruit_MAX31865 tankSensor = Adafruit_MAX31865(CS_tank,DI_pin,DO_pin,CLK_pin);
Adafruit_MAX31865 solenoidSensor = Adafruit_MAX31865(CS_solenoid,DI_pin,DO_pin,CLK_pin);

// ----- DISASTER DETECTION ----- //
// Pin connected to the button
const int dangerButton = 37;

// Variable to store the state of the button
volatile bool stopButtonPressed = false;

// ------------------------------ //

void setup() {
  // put your setup code here, to run once:
  
  // Define inputs (sensors)
  pinMode(pressureSensor1,INPUT_PULLUP);
  pinMode(pressureSensor2,INPUT_PULLUP);

  // Define inputs (limit switches)
  pinMode(upShiftLimitSwitchPin, INPUT_PULLUP);
  pinMode(downShiftLimitSwitchPin, INPUT_PULLUP);

  // Define outputs (relays)
  pinMode(upShiftPin,OUTPUT);
  pinMode(downShiftPin,OUTPUT);

  // Shift Buttons
  pinMode(upShiftButton, INPUT_PULLUP);
  pinMode(downShiftButton, INPUT_PULLUP);

  // Button to stop execution
  pinMode(dangerButton, INPUT_PULLUP);

  // Creates interrupt to stop Arduino
  attachInterrupt(digitalPinToInterrupt(dangerButton), stopArduino, FALLING);

  // Creates interrupt to perform shifts
  attachInterrupt(digitalPinToInterrupt(upShiftButton), controlSolenoid(upShiftPin,0.5), FALLING);
  attachInterrupt(digitalPinToInterrupt(downShiftButton), controlSolenoid(downShiftPin,0.5), FALLING);

  // Configures sensor as 2 wire RTDs
  tankSensor.begin(MAX31865_2WIRE);
  solenoidSensor.begin(MAX31865_2WIRE);

  

  // Begin serial communication
  Serial.begin(9600);
}

///////////////////////////////////////////////////////////////////////////////
void loop() {
/*
  delay(2000);
  executeShiftSequence(Profile4_Shift,Profile4_Time,Profile4_Times);
*/
  }
//////////////////////////////////////////////////////////////////////////////



// --------- FUNCTIONS --------- //

// Purpose: Interrupt Service Routine that sets value of stopButtonPressed to True, which will stop the system
void stopArduino() {
  stopButtonPressed = true;

  // Sets solenoid pins to low (closes both ends)
  digitalWrite(upShiftPin, LOW);
  digitalWrite(downShiftPin, LOW);

  if(stopButtonPressed) {
    Serial.println("STOP BUTTON PRESSED. SYSTEM SHUTDOWN");
    while(true) {
      // Do nothing, Arduino is stopped
    }
  }

}

// Takes in analogRead value and converts it to PSI
float voltageToPSI(float pressureValue) {

  // Scaling found from Excel Equation + Linear Fit
  // (pressureValue*5)/1024 converts it into a voltage, which is what the function is based off of
  float PSIVALUE = (24.987*((pressureValue*5)/1024))-12.466;
  return PSIVALUE;
}

// Purpose: Reads data from connected sensors
// Returns: Not sure if I want to return anything or just have it send serially from within function
void readSensorData() {

  // Reads the voltage of the pressure sensor, and then uses function to convert that to a PSI value
  float pressureSensor1Val = voltageToPSI(analogRead(pressureSensor1));
  float pressureSensor2Val = voltageToPSI(analogRead(pressureSensor2));


  // Temperature Values will need to be read as resistance from MAX31865
  float tank_temperature = tankSensor.temperature(RNOMINAL,RREF);
  float solenoid_temperature = solenoidSensor.temperature(RNOMINAL,RREF);

  // Print all our data as comma separated values
  Serial.println(String(pressureSensor1Val)+","+String(pressureSensor2Val)+","+String(tank_temperature)+","+String(solenoid_temperature));

}

// Purpose: Convert the value calculated by the position sensor to a distance from a voltage (in mm)
float voltageToDistance(int LVDTvalue) {
  // Total length that sensor can travel (in mm)
  float totalActiveLength = 50.8;
  float distanceValue = (totalActiveLength/1024)*LVDTvalue;
  return distanceValue;
}

// Purpose: Controls activation of solenoid from a digital output pin of an arduino
unsigned long controlSolenoid(int solenoidPin, float duration) {
  Serial.println("INSIDE OF FUNCTION");
  // So that input can be in seconds
  duration = duration*1000;

  // initializes limitSwitchPin variable
  int limitSwitchPin = 0;

  // Defines which limit switch should be checked
  if (solenoidPin == upShiftPin) {
    limitSwitchPin = upShiftLimitSwitchPin;
  } else {
    limitSwitchPin = downShiftLimitSwitchPin;
  }

  // Read data right before it opens
  //readSensorData();
  int startDistance = analogRead(LVDTsensor);
  // This makes the solenoid pin go high (opens valve)
  digitalWrite(solenoidPin, HIGH);

  // Starts a timer (that is used both to find the time to shift and compare to 'duration' so it can close automatically if it lasts too long)
  unsigned long startTime = millis();

  // Following loop terminates for either:
  // A: Limit Switch is pressed 
  // B: Timer exceeds duration specified in function
  while(digitalRead(limitSwitchPin)==HIGH & millis()-startTime<duration){
    delay(2);
    //readSensorData();
  }

  // endTime is found after one of the previous conditions is met, and the timeToShift\
     is simply the difference between the end and beginning of the shift
  unsigned long endTime = millis();
  unsigned long timeToShift = endTime - startTime;

  int endDistance = analogRead(LVDTsensor);
  float distanceTraveled = 0;

  if (endDistance>startDistance){
    distanceTraveled = endDistance-startDistance;
  } else {
    distanceTraveled = startDistance-endDistance;
  }


  float distance_in_mm = voltageToDistance(distanceTraveled);

  // Prints the time it takes to shift (in ms), and distance traveled
  //Serial.println("Time to Shift: "+ String(timeToShift) + " ms");
  //Serial.println("Distance Traveled: " + String(distance_in_mm) + " mm");
  Serial.println(String(timeToShift)+","+String(distance_in_mm));

  // Read data right before it closes
  //readSensorData();

  // Once the loop terminates, set the solenoid pin to low (close valve)
  digitalWrite(solenoidPin, LOW);


  return timeToShift;
}


// Purpose: Takes in the two arrays and uses the controlSolenoid() and delay() function with the two input arrays
void executeShiftSequence(const int pins[],const float durations[], int size) {

  Serial.println("START OF EXECUTE SHIFT SEQUENCE");

  int shiftPin = 0;
  unsigned long shiftTimes[size];

  // Determine if the shift is an upshift or a downshift 
  for(int i=0; i<size;i++){
    //Serial.println("\n"+String(i));
    if(pins[i] == 1){
      shiftPin = upShiftPin;
    }
    if (pins[i] == 0) {
      shiftPin = downShiftPin;
    }

    // Gets the time it takes to shift (measured from opening of solenoid to closing of solenoid)

    //Serial.println("START SHIFT");

    float shiftTime = controlSolenoid(shiftPin,0.5);

    //Serial.println("END SHIFT\n");

    // Load into array
    shiftTimes[i] = shiftTime;

    // wait to perform next shift until # of seconds in durations array passes
    delay(durations[i]*1000);
  }

  // After sequence is done, print the array for shift times !(maybe make this cleaner later)!
  Serial.println("Shift Times:");
  for(int i=0;i<size;i++) {
    if (i == 0){
      Serial.print("\n{" + String(shiftTimes[i]) + ",");
    }
    else if(i == size - 1) {
      Serial.print(String(shiftTimes[i])+"}");
    }
    else {
      Serial.print(String(shiftTimes[i])+",");
    }
  }
}

// Purpose: Reads values from sensors and checks that they are within specified range
// Returns: True (System OK), False (System not OK)
bool monitorSystemStatus() {
  float pressureSensor1Val = voltageToPSI(analogRead(pressureSensor1));
  float pressureSensor2Val = voltageToPSI(analogRead(pressureSensor2));

  // Checks to make sure that the pressure sensor values are within range
  if (pressureSensor1Val > PSI_HIGH || pressureSensor2Val > PSI_HIGH || pressureSensor1Val < PSI_LOW || pressureSensor2Val < PSI_LOW) {
    // Return false (not ok) if system does not pass pressure check
    return false;
  }

  // Checks to make sure that the temperature values are within range
  // TEMPERATURE CHECKING CODE GOES HERE

  // Return true (ok) if system passes both checks
  return true;
}

I have buttons attached to pins 35 and 36, and I want them to be hardware interrupts to the program:

  // Creates interrupt to perform shifts
  attachInterrupt(digitalPinToInterrupt(upShiftButton), controlSolenoid(upShiftPin,0.5), FALLING);
  attachInterrupt(digitalPinToInterrupt(downShiftButton), controlSolenoid(downShiftPin,0.5), FALLING);

I have tested each of the buttons with a different script, confirming that they sit at HIGH and change to LOW when pressed. However, when I try and implement them into this script, the controlSolenoid() function does not begin when I press that button. I even put a print statement at the beginning to check if the function gets ran upon pressing the button:

// Purpose: Controls activation of solenoid from a digital output pin of an arduino
unsigned long controlSolenoid(int solenoidPin, float duration) {
  Serial.println("INSIDE OF FUNCTION");

Everything else in the program has been tested extensively, and these interrupts (as well as the dangerButton hardware interrupt) are still not working. If anyone sees any errors or has a way to troubleshoot let me know!

Did you mention which board you're using?

If it's a Mega, pins 35 and 36 ain't pins that support hardware interrupts as far as I know.

Just realized I was using the wrong pins for the 2560. Changed to pins 18 and 19 for each of the buttons, but still not working.

Yeah you're right, I actually just changed that as you replied.

@domcobb_cobol - you can't pass arguments to the ISR function you specify in the attachInterrupt() call.

The call expects a pointer to a function taking no arguments.

The suggestion I found was to use global variables.

I have not looked at the rest of the logic.

Added: here you should probably just write two very similar functions both taking no arguments.

a7

In addition to what @alto777 has pointed out, ISRs also cannot return a value. They must be declared void
You should read this

1 Like

Just set a flag inside the ISR which means "need to control solenoid" and return. In your main function, test that flag and call a function to do the rest of the actions in your current ISR.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.