top of page
Recent Posts
Check back soon
Once posts are published, you’ll see them here.
Featured Posts

Matrix Keypad Interfacing with PIC Microcontroller | PIC18F452


Hi..!!!

Welcome to Embedded World. Today we talk about how to Matrix Keypad with micro-controller. We used matrix keypad when we build certain application like calculator, telephone etc. Matrix keypad is nothing but arranging push button switches in rows and columns(matrix format). so for that we required 8 pins of microcontroller. This matrix keypad wired internally, so when one of 16 button pressed a some pair of pins connected together and then its easy to detect pressed button.

1) Circuit Diagram

Here we interfaced LCD with PORT B of PIC controller. we can use lcd in either 4-bit mode or 8-bit mode. In 8-bit mode we required 8 data lines (D0-D7). But in 4-bit mode we required only 4 data lines (D4-D7), where in this mode 8-bit ASCII charter data and command data divided in two parts then send sequentially through data lines. 4-bit communication is little bit slower than 8-bit but it saves 4 data pins. thus

4-bit data is most commonly used.

so here in 4-bit data mode remaining 4 pins(D0-D3) are connected to ground (logic 0).

RW pins decides the lcd read/write operation, as here we only write data on lcd, not getting back any data so we connect RW pin to ground (logic 0) say write mode.

Initially assume all button are release, so there is no connection between row and column. so at that time no data recived at controller port pin. When any button pressed, the corresponding row and column connected (short circuited). So at moment of key pressed microconntroller received logic 1, at corresponding row and column port-pin (ex when key 1 pressed RD0 & RD1 goes logoc high or say short circuited). so using this logic pressed key can be detected.


2) Coding

Algorithm

1] Declare variable for key pressed

2] Assign PORT D for Keypad

3] Assign PORT B for LCD

4] Initialise LCD command

5] Display LCD data

6] Call Delay

7] Initially clear all key.

8] Send logic high to each row & simultaneously scan each column whether logic high detected or not.

9] If logic high detected , display corresponding character.

10] goto step 8.


3) Simulation Result

As MikroC has its inbuilt library function, it is easier to write code in mikroc compiler. just we need to initialise keypad library and lcd library and further implement code logic. Here logic is. for detecting which key is pressed we send logic high at each row n simultaneously check is logic high detect at column. If any column detect logic high, identify that row-column combination and display corresponding assign to that combination. So in short by scanning all row-column paralleled we can detect pressed key.


4) Burn Hex File

For loading program on controller I used PICkit3 Programmer. buy it from Amazon at RS.1100.


5) Hardware Output



For hardware implementation I used my PIC Development board. you can also used your board or just making simple connection on breadboard as per circuit diagram. Here we used external power source from 12Vac adapter then further it can be converted to 5V supply using rectifier and LM7805 and further provided to PIC MCLR pin and LCD supply pins. In lcd connection we connect variable resistor at pin 2 (VDD) of lcd to control the brightness of LCD. Data and control lines connected to PORT B. And connect keypad PORT D of controller.

So whatever key pressed is scan by controller and display it on lcd.





Download Here...!!!

You can download project hex file, proteus file, simulation, code, mikroc etc files here....


If you want to design your PIC Development Board, here its all required data, download and make your project..... ALL THE BEST !!!!



If you have any doubts, quires, suggestions for me please comment below or contact me on my number.



...Thanks For Visiting...




Follow Us
Search By Tags
Archive
  • Facebook Basic Square
  • Twitter Basic Square
  • Google+ Basic Square
bottom of page