DC Motor and Pushbutton Using Interrupt Function

Hi, I currently have this code. When the pushbutton is pressed the DC motor has to spin for a set time limit before coming to a stop. I would need to add the interrupt function into the code and I am not sure on how to do it. My motor is 380:1 Micro Metal Gearmotor HPCB 12V with Extended Motor Shaft and the driver carrier is MAX14870 Single Brushed DC Motor Driver Carrier. I am usuing Arduino UNO.

#include <DualMAX14870MotorShield.h>
// constants won't change. They're used here to
// set pin numbers:
const int buttonPin = 2;     // the number of the pushbutton pin
const int ledPin =  13;      // the number of the LED pin

#define LED_PIN 13
#define buttonPin 2

// variables will change:
int buttonState = HIGH;         // variable for reading the pushbutton status

DualMAX14870MotorShield motors;

void setup() 
{
  Serial.begin(9600);
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT);
}

void loop() {
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);
  // Show the state of pushbutton on serial monitor
  Serial.println(buttonState);
  // check if the pushbutton is pressed.
  // if it is, the buttonState is HIGH:
  if (buttonState == HIGH) {
    motors.enableDrivers();
     

  // run M1 motor with positive speed

  digitalWrite(LED_PIN, HIGH);

  //for (int speed = 0; speed <= 400; speed++)
  {
    motors.setM1Speed(200);
    delay(10000);
      motors.setM1Speed(0); 
  }
  
    //stopIfFault();
//if (millis() >= 10000) exit(0);
    //delay(2);
    
   
     
  }else 
    // turn LED off:
    digitalWrite(LED_PIN, LOW);
    motors.disableDrivers();
    delay(500);

  }

Why? If you write your code in such a way that it does use millis() based timings instead of delay() you (more than likely) don't need interrupts.

Please edit your post, select all code and click the </> button to apply so-called code tags and next save your post. It makes it easier to read, easier to copy and the forum software will display it correctly.

I need a non-blocking code, therefore I would need to use interrupts and I am not sure on how to integrate the interrupt function into my code. I currently have this code as I did some testing to validate if the pushbutton and DC motor are working. The overall purpose of my code is to start/run a motor once a pushbutton is pressed and stop after a given time limit

As already explained, using millis, you do not need to use interrupt.

Many beginners think that interrupts are a solution to all timing problems. But they are not. Unless you know a lot about interrupts, they usually cause more problems than they solve.
You only need interrupts when the processor needs to react really fast to an event. And by "fast" we mean the processor speed, not the human sense of time.
millis() is the method of choice in almost all cases of timing.