NO press detection using interrupts! Never ever use interrupts for that because a flaky switch will make your microcontroller stop into a grinding halt producing elusive problems. Whoever advices to use interrupts for buttons directly should be shot to death and then banned from this forum forever!
The best way is to have a timer running, use the counter from that timer in the main loop to see if a certain time period has elapsed (say 50 times per second). When the switch is pressed, have a counter count up, when the switch is open reset that counter. When the counter reaches a certain count (say 5 or 10) you can be certain the button has been pressed.
now that am banned and dead
man you left nothing for isis to do to me
this been discussed so many times in this forum particularly in a thread about interrupt vs pooling one.
1- it's always case depending
2- if there is no drama about making a small holding time after an interrupt been detected then test the button level by pooling it .it will have the same effect of what you said
3- i will find this a good idea on two cases : first if you can couple a switch interrupt with a timer interrupt that test the switch logic level after a period elapsed as you suggested. Or two if you can couple the button to a timer with gate control so where the timer reach a certain value is consider the button pressed ( for this pic you have only one timer (Timer 1) and one gate control. for both cases mcu will have minimum involvement.
4- this debate will continue as long as interrupt and pooling exists so no need to waste time about it really