Sunday, August 7, 2016

Matrix Keypad Interfacing with Microchip PIC

In this post, I will show, how to interface the Matrix Keypad and 16x2 LCD with one of the most popular Microchip PIC18F4550 microcontrollers.
I am using MPLABX Integrated Development Environment along with MPLAB XC8 Compiler for compiling the code.
The beauty of this post is that I will use the old existing keypad and 16x2 lcd library written for Cortex-M3 micro-controller, in this post.

The following image shows the connection of the PIC microcontroller with 16x2 LCD and Matrix Keypad.
Schematic Diagram

The LCD and Matrix Keypad Library are written in a generic format and can be ported for any other microcontroller.
LCD Library is handled to minimize the update time by checking the busy flag, but one can use the delay feature as well. To use the delay feature comment on the following line in the lcd_16x2.h header file.


#define USE_LCD_BUSY_FLAG             /**< Use Busy Bit instead of Delay.*/
Coming to the keypad part, the specialty of the keypad library is that, it works for pins that are not connected on a single port and not even in sequence. Apart from this one very good feature of this library is that, on pressing and holding a particular key for 2 seconds, the repeater mode is activated and key values are returned every 100 milli-second. Have a look at the following video, to know what this repeater mode is and how it can be useful for you.

Key-1 Pressed Simulation.

The following video is for previous post but still this code will behave in the same way.



Project Description
Keypad has 16 keys, whenever a key is pressed its counter increments by 1,  and a key press with a counter value is displayed on a 16x2 LCD. A keypad Hold feature is added in the algorithm which enables the repeat mode, which will increment counter speedily when pressing a key for more than 2 seconds.

3 comments:

  1. where is the firmware. Your Zip file dos not contain the code (Source file .c)

    ReplyDelete
    Replies
    1. I didn't get, why you are not able to find the source file.
      Go inside this folder:
      MatrixKeypad_PIC18F\MatrixKeypad.X\src
      Now you will see these folders
      app -> Contain Application Code
      config -> Configuration Code
      drivers -> driver codes

      Delete
  2. +brunelbalukidi
    I didn't get, why you are not able to find the source file.
    Go inside this folder:
    MatrixKeypad_PIC18F\MatrixKeypad.X\src
    Now you will see these folders
    app -> Contain Application Code
    config -> Configuration Code
    drivers -> driver codes

    ReplyDelete