dual linear actuators and attachinterrupt

Hi I'm working on a project and I need two linear actuators to move simultaneously in a repeated pattern until i stop the loop with an attachinterrupt.

Essentially i utilize two buttons to start the loop which pushes the actuators in and out continually.
then there is an attachinterrupt function which stops the loop and resets the buttons.

When the actuators aren't plugged into my arduino the code runs similarly to expected although some lights randomly come on. Although when i plug in the actuators external power supply it runs the code and calls the attachinterrupt function at the end without me pressing the button and stops the actuators from running after only one cycle. I'm not much of a programmer so please try to explain any ideas as simply as possible and thanks. here's the code I'm using.

int EnablePin1 = 13;
int PWMPinA1 = 11;
int PWMPinB1 = 3;
int EnablePin2 = 12;
int PWMPinA2 = 9;
int PWMPinB2 = 10;

int extendtimenormal = 1 * 1000; // 10 seconds, times 1000 to convert to milliseconds
int retracttimenormal = 1 * 1000; // 10 seconds, times 1000 to convert to milliseconds

const int powerbutton = 0;
const int powerled = 1;
const int resetbutton = 2;

const int freqbutton2 = 4;
const int depthbutton2 = 8;
const int freqled2 = 12;
const int depthled2 = A2;

int powerbuttonval = 0;
int resetbuttonval = 0;
int freqbutton2val = 0;
int depthbutton2val = 0;

int powerbuttonvalon = 0;
int resetbuttonvalon = 0;
int freqbutton2valon = 0;
int depthbutton2valon = 0;

int old_powerbuttonval = 0;
int old_resetbuttonval = 0;
int old_freqbutton2val = 0;
int old_depthbutton2val = 0;

int j;

void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(EnablePin1, OUTPUT);//Enable the board
pinMode(PWMPinA1, OUTPUT);
pinMode(PWMPinB1, OUTPUT);//Set motor outputs
pinMode(EnablePin2, OUTPUT);//Enable the board
pinMode(PWMPinA2, OUTPUT);
pinMode(PWMPinB2, OUTPUT);//Set motor outputs

pinMode(powerbutton, INPUT);
pinMode(resetbutton, INPUT);
pinMode(freqbutton2, INPUT);
pinMode(depthbutton2, INPUT);
pinMode(powerled, OUTPUT);
pinMode(freqled2, OUTPUT);
pinMode(depthled2, OUTPUT);

//the 0 corresonds to pin 2 the reset button
attachInterrupt(0, pin_ISR, RISING);
}

void loop() {
// put your main code here, to run repeatedly:
powerbuttonval = digitalRead(powerbutton);
if( powerbuttonval == LOW && old_powerbuttonval == HIGH) {
powerbuttonvalon = 1-powerbuttonvalon;
delay (10);
}

depthbutton2val = digitalRead(depthbutton2);
if( depthbutton2val == LOW && old_depthbutton2val == HIGH) {
depthbutton2valon = 1-depthbutton2valon;
delay (10);
}

freqbutton2val = digitalRead(freqbutton2);
if( freqbutton2val == LOW && old_freqbutton2val == HIGH) {
freqbutton2valon = 1-freqbutton2valon;
delay (10);
}

resetbuttonval = digitalRead(resetbutton);
if( resetbuttonval == LOW && old_resetbuttonval == HIGH) {
resetbuttonvalon = 1-resetbuttonvalon;
delay (10);
}

if ( powerbuttonvalon == 1)
digitalWrite(powerled,HIGH);
else
digitalWrite(powerled, LOW);

if ( depthbutton2valon == 1)
digitalWrite(depthled2,HIGH);
else
digitalWrite(depthled2, LOW);

if ( freqbutton2valon == 1)
digitalWrite(freqled2,HIGH);
else
digitalWrite(freqled2, LOW);

old_powerbuttonval = powerbuttonval;
old_resetbuttonval = resetbuttonval;
old_depthbutton2val = depthbutton2val;
old_freqbutton2val = freqbutton2val;

if ( depthbutton2valon == 1 and freqbutton2valon == 1 ) {

digitalWrite(EnablePin1, HIGH); // enable the motor
digitalWrite(EnablePin2, HIGH); // enable the motor
pushActuator1normal();
pushActuator2normal();

delay(extendtimenormal);
stopActuator1();
stopActuator2();
delay(10);//small delay before retracting

pullActuator1normal();
pullActuator2normal();
delay(retracttimenormal);
stopActuator1();
stopActuator2();

delay(10);//small delay before retracting

}
}

void pin_ISR() {

depthbutton2valon = 0 ;
freqbutton2valon = 0;

}

void stopActuator1() {
analogWrite(PWMPinA1, 0);
analogWrite(PWMPinB1, 0); // speed 0-255
}

void pushActuator1normal() {
analogWrite(PWMPinA1, 150);
analogWrite(PWMPinB1, 0); // speed 0-255
}

void pullActuator1normal() {
analogWrite(PWMPinA1, 0);
analogWrite(PWMPinB1, 150);//speed 0-255
}

void stopActuator2() {
analogWrite(PWMPinA2, 0);
analogWrite(PWMPinB2, 0); // speed 0-255
}

void pushActuator2normal() {
analogWrite(PWMPinA2, 150);
analogWrite(PWMPinB2, 0); // speed 0-255
}

void pullActuator2normal() {
analogWrite(PWMPinA2, 0);
analogWrite(PWMPinB2, 150);//speed 0-255
}

How are your pushbuttons wired? Do you have pullup or pulldown resistors on them so they don't float when not pushed and cause false signals?

@kmforest, Please modify your post and use the code button </> so your code looks like this and is easy to copy to a text editor. See How to use the Forum Your code is too long to study quickly.

If you remove the delay()s from your code and use millis() to manage timing as in Several Things at a Time then you are unlikely to need an ISR to detect the button.

…R