button and interrupts: why delay is different when used inside int0_ISR?

Hi all,
i’d like to increase/decrease the delay of a blinking led with two buttons.
I used the interrupt to have the button responsive without waiting for the delay i set.
I also want to increase/decrease continuously the bpm value till i press the button, but…not so fast as in i don’t type any “delay” function.

I obtain what i want, but i don’t understand why the delay inside int0_ISR and int1_ISR, in particular delay(10000) is not 10 seconds but more less.

I had to put this value because if i use lower value it increases too quickly. Only with this high value i can keep the button pressed and see the value increasing not so fast.

Why delay(10000) is not 10 seconds???

Here is my code

int pinButton1	= 2; 	//the pin where we connect the 1st button (+)
int pinButton2  = 3; 	//the pin where we connect the 2nd button (-)
int LED			= 13; 	//the pin we connect the LED

float bpm		= 60; 	// initial value

void setup() {
  attachInterrupt(0, int0_ISR, RISING); 
  attachInterrupt(1, int1_ISR, RISING); 

  pinMode(pinButton1, INPUT); 	//set the button1 pin as INPUT  
  pinMode(pinButton2, INPUT); 	//set the button2 pin as INPUT
  pinMode(LED, OUTPUT); 		//set the LED pin as OUTPUT
void loop() {

      digitalWrite(13, HIGH);   // turn the LED on 

      digitalWrite(13, LOW);    // turn the LED off
     Serial.print("actual BPM: ");

void int0_ISR(void) { 

 // increasing interrupt 
	digitalWrite(LED, HIGH); 
 { bpm++; 									// counter update
 Serial.println(bpm, DEC); 
 delay(10000); 								// delay : why so much ?
 } while(digitalRead(pinButton1) != 0); 	// wait until the button is pressed
 delay(800); 								// wait to avoid button bounce
 digitalWrite(LED, LOW); 
 Serial.print("interrupt0 - BPM increased: ");
 if (bpm >= 240) bpm = 240;				// higher limit


void int1_ISR(void) { 

 digitalWrite(LED, HIGH);
 { bpm--; 									// counter update
 Serial.println(bpm, DEC);
 delay (10000);								// delay : why so much ?
 } while(digitalRead(pinButton2) != 0);		// wait until the button is pressed
 delay (800); 								// wait to avoid button bounce
 digitalWrite(LED, LOW); 
 Serial.print("interrupt1 - BPM decreased: ");
 if (bpm <= 30) bpm = 30;					// lower limit

delay() depends on interrupts. Serial.print() depends on interrupts. Interrupts are automatically disabled in an ISR. Can you see why there may be a problem with your ISRs ?

Also, all variables updated in an ISR should be declared as volatile.

Can you please describe what your program should do as there is certainly going to be a better way to do it. You probably don't need to use an interrupt at all.

If you just want to detect when buttons are pressed by a person you don't need to use interrupts.

Look at how to manage timing without using delay in the demo several things at a time.