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) {
Thanx for your reply,
from u r code and u r explanation i have understand how to use key scanning ....finally i got output...i am doing project on"PULSE GENERATOR"..... i am using keypad with LCD 4x20 display in that by using key pad i manage cursor moving positions .....when i press down key the cursor moves to very fastly from 1st line to 4th line ..... my requirement is when i press key (Holding some time) cursor position goes to next line only...that is requirement .....finally i got it ....thanx for u r help...and if u want more clarification about my project just reply me .....
i am using this logic in timer_IRQ......
if(((LPC_GPIO1->PIN&r5)!=0)&((LPC_GPIO1->PIN&r3)!=0)) { key_pad=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.