hi , i am not well in english ,try to understand my language.
here i am using 4x4 matrix keypad ....
problem: key de bouncing problem
requirement: when i press key and i hold it some time. i want to display only one time that key in LCD but it is not displayed one time (so many numbers are printed on lcd)...
check my code
#include <LPC177x_8x.H> #include "7Seg.h" #include "lcd.h" unsigned char keypad (void) { unsigned char key; LPC_GPIO1->CLR|=(c1|c2|c3|c4|r1|r2|r3|r4|r5); while(1) { LPC_GPIO1->CLR|=c1; LPC_GPIO1->SET|=(c2|c3|c4); // first column = 0 if((LPC_GPIO1->PIN&r1)==0) { Delay_ms(100); if((LPC_GPIO1->PIN&r1)==0) { key='0'; keypad_delay(); return key; } } if((LPC_GPIO1->PIN&r2)==0) { Delay_ms(100) if((LPC_GPIO1->PIN&r2)==0) { key='4'; keypad_delay(); return key; } } if((LPC_GPIO1->PIN&r3)==0) { Delay_ms(100); if((LPC_GPIO1->PIN&r3)==0) {
My short demo code already handles the issue of having the down key only move one step down unless you press it multiple times with release in between.
And the demo code is trivial to extend to also handle long presses - to either generate key repeats at some suitable frequency for a long press or to produce an alternative return code.