I have been watching videos, reading tutorial on switch bouncing But it's all over my head. I understood What happens if we press the buttons. When we press push button down, it wont make immediate contact, it will shift around a little bit! Like button is pressed multiple times. Button may make contact on and off for a few milliseconds before settling down to the state we want.
When working with microcontrollers,
I see in many place programmers do not care much about bouncing switches and just add a 50ms delay after the first bounce. Adding a delay force the controller to stop for a particular time period,


I don't understand PIC program given in tutorial https://www.allaboutcircuits.com/technical-articles/switch-bounce-how-to-deal-with-it/
In while loop, first we check the button if the button is pressed, increment BTN_press
I don't understand the logic of the rest of the code,
When working with microcontrollers,
I see in many place programmers do not care much about bouncing switches and just add a 50ms delay after the first bounce. Adding a delay force the controller to stop for a particular time period,


I don't understand PIC program given in tutorial https://www.allaboutcircuits.com/technical-articles/switch-bounce-how-to-deal-with-it/
In while loop, first we check the button if the button is pressed, increment BTN_press
I don't understand the logic of the rest of the code,