Counting number of push button press by external interrupt
1) It is better, if you can deal with debouncing in hardware itself. If possible, put an appropriate capacitor on the interrupt pin to ground.

2) In software you can deal like: (Assuming that bouncing can last up to 50s)

void my_interrupt_handler()
{
 interrupt_time = currentmilliseconds();

 if (interrupt_time - last_interrupt_time &gt; 50) 
 {
   press++;
   last_interrupt_time = interrupt_time;
 }

}


last_interrupt_time has 0 initial value. The code increments the press value for the very first press. But it will not increment for 50 ms, no matter how many button interrupts come in between due to bouncing. This will efficiently work only if the microcontroller supports interrupts within interrupts, otherwise it has chance of missing timer overflow interrupt.

3) Another method is simply adding a 50 ms delay after incrementing press. It works. But not a good method though.

4)  Another idea, by using a flag variable:

void my_interrupt_handler()
    {     
      if (flag == 0)
         { 
          press++;
          flag = 1 
         }
    }


flag is a volatile variable shared between main() and ISR. Code is written in main() such that it reinitialises flag back to 0 only after counting 50 ms. So this is like disabling button interrupts for 50 ms. Anyway, Humans cant press faster than that.