How to interface keypad with PIC16F877




This PIC microcontroller tutorial provides a simple method to interface any keypad (e-g 4×4 or 4×3 etc) with PIC16F877 microcontroller.

Interfacing keypad with PIC16F877

This code is written in C language using MPLAB with HI-TECH C compiler. You can download this code from the ‘Downloads‘ section at the bottom of this page.

In this post, it is assumed that you know, how to interface LCD with PIC16F877 microcontroller, If you don’t then please read this page.
The circuit required to interface keypad with PIC16F877[1] is shown below.

Interfacing keypad with PIC16F877 schematic

The result of simulating the code in Proteus is shown above in the figure. This code is written in such a way that when you press any key from the keypad, then the value of that key is displayed on the LCD. For example, in the above figure LCD screen is displaying ‘5’, because this picture was taken after pressing ‘5’ from the keypad.

In the above circuit, RD0, RD1 and RD4:7 pins are used to interface LCD with PIC16F877. LCD is used here just to show the pressed key value. 8 pins of PORTB are used to interface 4×4 keypad. 4 pins are used to attach columns and 4 pins are used to attach rows and scanning algorithm code is used to check for any pressed key.

Code

The main function code is shown below.

Downloads

Keypad interfacing code using PIC16F877 was compiled in MPLAB v8.85 with HI-TECH C v9.83 compiler and simulation was made in Proteus v7.10. To download code and Proteus simulation click here.

 

For more detail: How to interface keypad with PIC16F877




Current Project / Post can also be found using:

  • keypad interfacing with pic16f877a pdf
  • 4×4 keypad interfacing with pic16f877a
  • 4×4 matrix keypad interfacing with pic16f877a
  • keypad interfacing with pic microcontroller

Leave a Comment

*
= 3 + 1

Read previous post:
PIC16F877 internal EEPROM
PIC16F877 internal EEPROM code and Proteus simulation

This post provides the internal EEPROM reading and writing code for PIC16F877 microcontroller. As we know[1], PIC16F877 microcontroller has 256 x...

Close
Scroll to top