Sunday, December 07, 2014

Matrix [4x4] Keypad interfacing with PIC Microcontroller [ PIC18f2550 ] in Proteus [Step by Step]




 Matrix [4x4] Keypad  interfacing with PIC Microcontroller [ PIC18f2550 ] in Proteus [Step by Step]
 Matrix [4x4] Keypad  interfacing with PIC Microcontroller [ PIC18f2550 ] in Proteus [Step by Step]


Basically a matrix keypad[ 4x4] can be compared as a keyboard of microcontroller .The keypad contains 16 buttons .Internal architecture of keypad described below :
 Matrix [4x4] Keypad  interfacing with PIC Microcontroller [ PIC18f2550 ] in Proteus [Step by Step]
Taken from Internet

You can see  the button's structure  .Here each row is connected with ground through 10k ohm resistor . Now consider that A=1, B=0,C=0,D=0 and column A get +5v .At this situation , if you press   button[A,E]  , the E link get +5v .In this way for button[A,F] , F=+5v or 1, button[A,G] , G=1, button[A,H] , H= 1.
Listen , if we can make ABCD(1000) ,ABCD(0100),ABCD(0010), ABCD(0001) through a loop . Now any button  pressed  , we can uniquely identify the button .In this way the matrix keypad works .

Now Create a project in Proteus :

Proteus Project :

Please follow the steps




I am just trying to make easy for beginner .Now follow the instruction for pick parts from library .




Now pick  PIC18F4550  microcontroller , 22pf capacitor ,crystal , LCD DISPLAY [LM016L] , keypad  from proteus library .Now see the complete circuit given below :
 Matrix [4x4] Keypad  interfacing with PIC Microcontroller [ PIC18f2550 ] in Proteus [Step by Step]
 Matrix [4x4] Keypad  interfacing with PIC Microcontroller [ PIC18f2550 ] in Proteus [Step by Step]

Here i have connected each column with +5v instead of GND and now i am going to provide (1000) ,(0100),(0010),(0001) in each row respectively .So if any button  is pressed we get 0 according to this.
Now We have completed the Circuit and create a project in MikroC .

MikroC Project :

If  you are a beginner , please follow the steps given below :

Source Code :

  


  sbit LCD_RS at RB7_bit;  
  sbit LCD_EN at RB6_bit;  
  sbit LCD_D4 at RB5_bit;  
  sbit LCD_D5 at RB4_bit;  
  sbit LCD_D6 at RB3_bit;  
  sbit LCD_D7 at RB2_bit;  
  sbit LCD_RS_Direction at TRISB7_bit;  
  sbit LCD_EN_Direction at TRISB6_bit;  
  sbit LCD_D4_Direction at TRISB5_bit;  
  sbit LCD_D5_Direction at TRISB4_bit;  
  sbit LCD_D6_Direction at TRISB3_bit;  
  sbit LCD_D7_Direction at TRISB2_bit;  
  // End LCD module connections  
  char ch[]="   ";  
  int j=0,ak=0,i=0;  
  void main() {  
  ADCON1=0x0F;  
  CMCON=7;  
  TRISA.F0=1;  
  TRISA.F1=1;  
  TRISA.F2=1;  
  TRISA.F3=1;  
  TRISC.F0=0;  
  TRISC.F1=0;  
  TRISC.F2=0;  
   TRISC.F4=0;  
  Lcd_Init();  
   Lcd_Cmd(_LCD_CLEAR);    // Clear display  
  Lcd_Cmd(_LCD_CURSOR_OFF);  
  delay_ms(200);  
  j=0;  
   while(1){  
    PORTC=0x00;  
    LCD_Out(1,1,"Matrix Keypad");  
    ak=5;  
    delay_ms(200);  
   while (ak==5){  
  PORTC=0x01;       //  
  if(PORTA.F0==1 & PORTA.F1==0 & PORTA.F2==0 & PORTA.F3==0) {  
   ak=2;  
   Lcd_Chr(2,4,'7');  
    ch[j]='7';  
   j++;  
  }  
  if(PORTA.F0==0 & PORTA.F1==1 & PORTA.F2==0 & PORTA.F3==0) {  
   Lcd_Chr(2,4,'4');  
   ak=2;  
    ch[j]='4';  
   j++;  
  }  
  if(PORTA.F0==0 & PORTA.F1==0 & PORTA.F2==1 & PORTA.F3==0) {  
  Lcd_Chr(2,4,'1');  
      ch[j]='1';  
   ak=2;  
   j++;  
  }  
   if(PORTA.F0==0 & PORTA.F1==0 & PORTA.F2==0 & PORTA.F3==1) {  
     Lcd_Chr(2,4,'C');  
    ch[j]='C';  
   ak=2;  
   j++;  
  }  
   PORTC=0x02;  
   if(PORTA.F0==1 & PORTA.F1==0 & PORTA.F2==0 & PORTA.F3==0) {  
   Lcd_Chr(2,4,'8');  
  ch[j]='8';  
   ak=2;  
   j++;  
  }  
  if(PORTA.F0==0 & PORTA.F1==1 & PORTA.F2==0 & PORTA.F3==0) {  
   Lcd_Chr(2,4,'5');  
  ch[j]='5';  
   ak=2;  
   j++;  
  }  
  if(PORTA.F0==0 & PORTA.F1==0 & PORTA.F2==1 & PORTA.F3==0) {  
   Lcd_Chr(2,4,'2');  
  ch[j]='2';  
   ak=2;  
   j++;  
  }  
   if(PORTA.F0==0 & PORTA.F1==0 & PORTA.F2==0 & PORTA.F3==1) {  
    Lcd_Chr(2,4,'0');  
   ch[j]='0';  
   ak=2;  
   j++;  
  }  
  /////////////////////////  
  PORTC=0x04;        //  
   if(PORTA.F0==1 & PORTA.F1==0 & PORTA.F2==0 & PORTA.F3==0) {  
   Lcd_Chr(2,4,'9');  
  ch[j]='9';  
   ak=2;  
   j++;  
  }  
  if(PORTA.F0==0 & PORTA.F1==1 & PORTA.F2==0 & PORTA.F3==0) {  
    Lcd_Chr(2,4,'6');  
   ch[j]='6';  
   ak=2;  
   j++;  
  }  
  if(PORTA.F0==0 & PORTA.F1==0 & PORTA.F2==1 & PORTA.F3==0) {  
    Lcd_Chr(2,4,'3');  
    ch[j]='3';  
   ak=2;  
   j++;  
  }  
   if(PORTA.F0==0 & PORTA.F1==0 & PORTA.F2==0 & PORTA.F3==1) {  
    Lcd_Chr(2,4,'=');  
    ch[j]='=';  
   ak=2;  
   j++;  
  }  
   /////////////////////////  
  PORTC=0x10;        //  
   if(PORTA.F0==1 & PORTA.F1==0 & PORTA.F2==0 & PORTA.F3==0) {  
   Lcd_Chr(2,4,'/');  
  ch[j]='/';  
   ak=2;  
   j++;  
  }  
  if(PORTA.F0==0 & PORTA.F1==1 & PORTA.F2==0 & PORTA.F3==0) {  
    Lcd_Chr(2,4,'*');  
   ch[j]='*';  
   ak=2;  
   j++;  
  }  
  if(PORTA.F0==0 & PORTA.F1==0 & PORTA.F2==1 & PORTA.F3==0) {  
    Lcd_Chr(2,4,'-');  
    ch[j]='-';  
   ak=2;  
   j++;  
  }  
   if(PORTA.F0==0 & PORTA.F1==0 & PORTA.F2==0 & PORTA.F3==1) {  
    Lcd_Chr(2,4,'+');  
    ch[j]='+';  
   ak=2;  
   j++;  
  }  
  }  
   }  
  }  




 Now follow the instructions, how to create .hex file and save .


 Now go to Proteus and Run the Project .



 Matrix [4x4] Keypad  interfacing with PIC Microcontroller [ PIC18f2550 ] in Proteus [Step by Step]

 In this way you will able to interface Keypad with Microcontroller .

Result Video :



Download This Project(Google Drive)


Thank You!



5 comments:

  1. The link is down! :( Please re-upload.

    ReplyDelete
  2. I think this article is not up to date you can add more information about it. You can also check out lesco duplicate bill it provide you complete information about it.

    ReplyDelete

Ain't getting any visitors!
Please Share and Bookmark posts.

Tags

: (1) 18F2550 (1) 36KHz (3) and (1) arduino (1) Based (1) battery (1) Bipolar (1) Blinking (1) blinks (1) Bluetooth (1) bluetooth device interfacing (1) bluetooth module (1) button (1) circuit (1) clock (1) control (1) crystal oscillator (3) Db9 (1) DC Motor (2) digital (2) Digital Voting Machine (1) digital voting machine using pic (1) display (2) DS1307 (1) electronic (1) embedded c programming tutorial (11) embedded c tutorial (11) experiment kit (4) external interrupt (4) flash (1) flashing (1) Gas Leakage detector (1) HC-06 (1) home (1) how (1) How to (10) i2c tutorial (1) in (1) indicator (1) infrared Connection (3) interface (8) interfacing (3) Interrupt (3) Introduction (1) IR Connection (3) IR Receiver (4) IR Transmitter (4) key pad (1) keyboard (1) keypad (1) lavel (1) Lcd 16x2 (2) lcd 2x16 (2) led (1) lm35 (2) LPG (1) machine (1) make (1) Make bootloader (1) making (1) matrix (1) max232 (1) membrane keyboard (2) meter (2) Micocontroller (1) microchip (4) microchip pic (2) microchips (3) microcontroller (9) microcontroller based (3) microcontroller programming (3) Microcontroller Project (4) Microcontroller Projects (1) microcontroller_project (2) microcontrollers (4) Microprocessor (2) mikroC (5) mikroc code to start and stopstart and stop dc motor (1) mikroc pro for pic (2) Motion detector (1) MQ-9 Gas Sensor (1) musical (1) NEC Protocol (4) pcb (5) PIC (3) pic controller (11) pic microcontroller (11) pic microcontroller tutorial (11) pic programming (1) pic programming in c (12) pic proteus (1) Pic Tutorial (12) pic18 (2) pic18f2550 (11) picmicrocontroller (4) picRFモジュール (1) PIR Motion Sensor (1) printed circuit board (1) proteus (6) pulse width modulation (1) push (1) push button (1) PWM (1) real (1) rf transmitter (3) Rs 232 (1) Rs232 (1) scroll (1) scrolling (1) Serial communication (1) Serial Connection (1) Serial Port (1) serial port rs232 (1) Servo Motembedded c programming tutorial (1) simulation (2) Soil Moisture Meter (1) speed control (1) step by step (7) step bystep (1) Stepper Motor (2) text (2) Thief Detector (1) time (1) timer (4) timer0 (4) tone (1) TSOP38236 Receiver (4) tutorial (2) Unipolar (1) USART Connection (1) USB (1) usb 1.0 (1) USB bootloadere (1) USB HID (1) using (9) voltmeter (1) voting (1) water level indicator (3) with (2) work (1)

Traffic Feed


Live Traffic Feed
Visitor Tracking

Leave Your Message Here

Name

Email *

Message *

Like on Facebook