Microcontroller › AVR › 4×4 Keypad Debounce › My goal is to do software
June 18, 2015 at 7:31 am
#12999
Setebwer
Participant
My goal is to do software debounce. I've made this code that's working only for * 0 # D buttons. So while I'm pushing * MCU is waiting. How should I modify this code for debouncing 1, 2 ,3, 4, 5, 6, 7, 8, 9, A, B, C buttons as well?
int main(void)
{
while(1)
{
…
if(keypad==0) // When zero is pushed…
{
while(!(PINC&(1<<PC5))); //Waiting while zero is pushed
_delay_ms(50);
}
}
}
My 4×4 keypad hardware connections to AVR
DDRC=0b00001111; //upper 4 bits are declared input and lower 4 bits are declared output(4×4 Keypad is connected)
PORTC=0b11111111;//lower 4 bits are given high value and pull-up are enabled for upper 4 bits