PIC16F877A and a 4x4 Keypad

Status
Not open for further replies.

Legatus

Newbie level 2
Joined
Oct 22, 2008
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,293
pic16f877 and 4×5 keypad

I have a question for all the brilliant minds of EDA board:

How can I interface a 4x4 keypad with a PIC16F877A?

Oh, and I'm using CCS compiler.

Thanks
 

pic16f877a keypad

Try h**p://w*w.ccsinfo.com/forum/ for examples. Replace the * of course. The principle will be the same for most Pics, just change pin assignments.
 

keypad using pic16f877a

I did this one for an 8052 using Ke*l compiler. This one is for 3x4, but gives the general idea. Should be easily adaptable for a PIC.

//Read Keypad and returns Digit Value

unsigned char GetKey(void) // Get Keypress
{
sbit C3 = 0xA4; //P2.4
sbit C2 = 0xA5; //P2.5
sbit C1 = 0xA6; //P2.6
sfr P2 = 0xA0; //Port 2 Lower nibble connection

unsigned char Digit, KeyRead;

C1 = 0; C2 = 1; C3 = 1; // Column 1 On
KeyRead = (P2 & 0x0F);
if (KeyRead == 14) Digit = 1; // Read Rows and Translate
if (KeyRead == 13) Digit = 4;
if (KeyRead == 11) Digit = 7;
if (KeyRead == 7) Digit = 10; // Cancel Key

C1 = 1; C2 = 0; C3 = 1; // Column 2 On
KeyRead = (P2 & 0x0F);
if (KeyRead == 14) Digit = 2;
if (KeyRead == 13) Digit = 5;
if (KeyRead == 11) Digit = 8;
if (KeyRead == 7) Digit = 0;

C1 = 1; C2 = 1; C3 = 0; // Column 3 On
KeyRead = (P2 & 0x0F);
if (KeyRead == 14) Digit = 3;
if (KeyRead == 13) Digit = 6;
if (KeyRead == 11) Digit = 9;
if (KeyRead == 7) Digit = 11; // Call Key

C1 = 0 ; C2 = 0; C3 = 0;
while ((P2 & 0x0F) != 0x0F) {} // Waits for Key Release
Sounder = 0;
return Digit;
}
 

keypad interfacing with pic16f877a

Thanks, gave *me* an idea. I'll try to convert it to PIC

** <- edit
 

i don't understand?
interface matrix 4*4 keypad with pic16f877a:roll:
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…