All the above methods block the program execution. If this is not a problem then it I guess ok.
But if the PIC must do other things, it is better to have a ticker in a timer interrupt routine and count up when a key is pressed. Periodically check the ticker for the required value and decide what to do.
That way, program does not stay in a closed loop until button release.
Ioannis
Bookmarks