Hey all,
I was checking out Gooligum's tutorials and came across this C code for switch debouncing:
for (db_cnt = 0; db_cnt < 10; )
{
_delay_ms(1);
if (GPIObits.GP3 == 0)
db_cnt++;
else
db_cnt = 0;
}
I understand how it all works but once the routine starts doesn't it get stuck in the for loop?(assuming the button never gets pressed long enough). This is all fine if that is all the program wants to do but if I want other things, like multiple buttons, or other switches to monitor, or even spitting out data to something how can I amend this code? Could I just stick something else in the 'for conditions' or is it more complex than that?
I was checking out Gooligum's tutorials and came across this C code for switch debouncing:
for (db_cnt = 0; db_cnt < 10; )
{
_delay_ms(1);
if (GPIObits.GP3 == 0)
db_cnt++;
else
db_cnt = 0;
}
I understand how it all works but once the routine starts doesn't it get stuck in the for loop?(assuming the button never gets pressed long enough). This is all fine if that is all the program wants to do but if I want other things, like multiple buttons, or other switches to monitor, or even spitting out data to something how can I amend this code? Could I just stick something else in the 'for conditions' or is it more complex than that?