Interfacing 4*4 keypad with PIC16F877A

General discussion on mikroC.
Post Reply
Author
Message
alexiumus
Posts: 2
Joined: 05 Aug 2010 15:08

Interfacing 4*4 keypad with PIC16F877A

#1 Post by alexiumus » 09 Aug 2010 09:38

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...

braus
Posts: 167
Joined: 25 Jul 2007 22:55
Location: Mexico, city.

Re: Interfacing 4*4 keypad with PIC16F877A

#2 Post by braus » 09 Aug 2010 17:31

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.
Best Regards
Omar Galicia
Mexico City

User avatar
ranko.rankovic
Posts: 433
Joined: 11 Jun 2010 09:22

Re: Interfacing 4*4 keypad with PIC16F877A

#3 Post by ranko.rankovic » 10 Aug 2010 13:09

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
Ranko Rankovic
mikroElektronika [Support Department]

Post Reply

Return to “mikroC General”