Button debouncing
Posted: Thu Apr 05, 2018 1:42 am
I received this via PM:
Frankur, please don't ask questions via PM.
Everyone benefits (and everyone can contribute), when questions and answers are in public.
How many buttons do you have, and how are they connected? (i.e. are they multiplexed?)
What exact PIC device are you using?
Frankur wrote:Hi Ric, sorry about my english, that's because i'm from Mexico, i checked some your post in the microchip forum, i'm very interested in this
''My recommendation would be to not use the pin change interrupts at all.
Rather, run a timer interrupt at around 100Hz.
Scan all your buttons on each interrupt.
Whenever one changes, set a counter related to that button to a low value, say 3 to 5.
Each following interrupt, decrement the counter if the button hasn't changed.
When you decrement the counter from 1 to 0, treat that as a new state for that button.''
I would like if you could copy and paste the code you use to debounce your buttons so i can understand it and adapt it to my proyect.
It will be so cool if you could to that please. Thank you.
Frankur, please don't ask questions via PM.
Everyone benefits (and everyone can contribute), when questions and answers are in public.
How many buttons do you have, and how are they connected? (i.e. are they multiplexed?)
What exact PIC device are you using?