Page 1 of 1

Interfacing 4*4 keypad with PIC16F877A

Posted: 09 Aug 2010 09:38
by alexiumus
Hello Am Alex. I have been trying to interface 4*4 keypad with PIC16F877A ...using proteus isis and MPLab IDE...i have been searching for relevant information...can someone simply tell me where can I find keypad_read and other functions...and also header files...am using portc as keypad input. thank u...

Re: Interfacing 4*4 keypad with PIC16F877A

Posted: 09 Aug 2010 17:31
by braus
Hello alexiumus, I saw you has been writting assembler code and that says me that you are familiarized with microchip products so I can tell you two things in order you can solve the problem you are in;
1- As you know PIC16F877A is very capable to interact with a 4*4 keypad and whatever moficication this keypad has. This is true because PIC16F877A counts with a interrupt on change capable port that facilitates programmer work, this port is called PORTB and in order it works prior way you have to set it's four more significant bits as an input while the four less significant bits have to be configured as en exit, besides prior you have to clear #RBPU bit at OPTION_REG and have to enable RBIE and RBIF bits.
2- Easiest way to interface a 4*4 keypad is to use Keypad pre built mikroC function.

Re: Interfacing 4*4 keypad with PIC16F877A

Posted: 10 Aug 2010 13:09
by ranko.rankovic
Hello alexiumus,

As braus said, our Keypad 4x4 uses matrix system, so when connected on port (our library is written for PortB), half of port is used as output, half as input. In fact, the MCU senses if one of the keypads are pressed.

Functions that are used for Keypad 4x4 are Keypad_Init (initializes keypad), Keypad_Key_Press (the code of a pressed key is 1 to 16, and if no key is pressed, returns 0) and Keypad_Key_Click (the code of a pressed key is 1 to 16, and if no key is pressed, returns 0).
As you can see Keypad_Key_Press and Keypad_Key_Click are similar functions, only that Keypad_Key_Click is blocking function, so key needs to be pressed and released before code is sent.

You can find examples for Keypad 4x4 here.

Best regards,
Ranko Rankovic