|
|
View previous topic :: View next topic |
Author |
Message |
aldinlapinig
Joined: 16 Dec 2005 Posts: 22
|
Keypad Interfacing...Help |
Posted: Fri Jan 13, 2006 8:10 pm |
|
|
Hi,
I just learned to interface a 4x3 alphanumeric keypad with PIC. I've been using the KBD.C driver of the CCS C Compiler. What I want to know now are the following:
1. How to detect a "press-hold" of a certain key?
2. How to decode the letter characters of the keypad? I mean,if I want to input letter C, I have to press number 2 thrice?
Any idea? Please. I need help on this.
Thanx a lot
-=alDin=- |
|
|
MikeValencia
Joined: 04 Aug 2004 Posts: 238 Location: Chicago
|
|
Posted: Sat Jan 14, 2006 5:27 pm |
|
|
You'll need states such as:
STATE_NO_KEYS_PRESSED
STATE_KEY_1_PRESSED
STATE_KEY_2_PRESSED
STATE_KEY_3_PRESSED
...
STATE_KEY_nth_PRESSED
In "STATE_NO_KEYS_PRESSED", scan the keypad for any activity, decode that activity, and then jump to the appropriate STATE_KEY_x_PRESSED state. When in these pressed states, then scan the keypad to look for the no_key_pressed scan. |
|
|
aldinlapinig
Joined: 16 Dec 2005 Posts: 22
|
i did similar stuff already... |
Posted: Sat Jan 14, 2006 8:47 pm |
|
|
I did similar stuff already but i am having a hard time dtermining the long press ("press-hold") of a key.... and i want to use the letters on the 4x3 keypad. Thanx for the immediate response...
I think I need more idea.
-=alDin=- |
|
|
MikeValencia
Joined: 04 Aug 2004 Posts: 238 Location: Chicago
|
|
Posted: Mon Jan 16, 2006 1:25 pm |
|
|
When you say that you want to use the letters on the keypad, i did something similiar to programming alphanumeric names for a commercial frying machine:
Code: |
/* Note: 0x02 means SPACE */
BYTE CONST SMS_ZERO[2] = {'0', 0x02};
BYTE CONST SMS_ONE[2] = {0x02, '1'};
BYTE CONST SMS_TWO[5] = {'A', 'B', 'C', '2', 0x02};
BYTE CONST SMS_THREE[5] = {'D', 'E', 'F', '3', 0x02};
BYTE CONST SMS_FOUR[5] = {'G', 'H', 'I', '4', 0x02};
BYTE CONST SMS_FIVE[5] = {'J', 'K', 'L', '5', 0x02};
BYTE CONST SMS_SIX[5] = {'M', 'N', 'O', '6', 0x02};
BYTE CONST SMS_SEVEN[6] = {'P', 'Q', 'R', 'S', '7', 0x02};
BYTE CONST SMS_EIGHT[5] = {'T', 'U', 'V', '8', 0x02};
BYTE CONST SMS_NINE[6] = {'W', 'X', 'Y', 'Z', '9', 0x02};
|
Looks like you should store the patterns in arrays.
You then would reference the array if you press the same key a couple of times. It would all be in the same 'substate', but you'll need a counter in each. If a different key is pressed, then you reset the counter. The counter should also wrap around once you hit the last character. In other words, hitting the number '2' several times should give you:
2 A B C 2 A B ...etc. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|