---
+ Post New Thread
Results 1 to 19 of 19
  1. #1
    Member level 2
    Points: 737, Level: 5
    bskumar7080's Avatar
    Join Date
    Feb 2010
    Location
    India
    Posts
    48
    Helped
    4 / 4
    Points
    737
    Level
    5

    How to interface 4x4 Keypad with PIC microcontroller

    Hi all,

    How to interface 4 x 4 Keypad with PIC microcontroller . How to check the 4 x 4 keypad, anyone could provide schematic.

    •   Alt27th October 2010, 04:30

      advertising

        
       

  2. #2
    Full Member level 3
    Points: 1,965, Level: 10

    Join Date
    Jan 2010
    Location
    kerala
    Posts
    155
    Helped
    55 / 55
    Points
    1,965
    Level
    10

    Re: How to interface 4x4 Keypad with PIC microcontroller

    Dear firend,

    It is easy one. Make 4 pin as input and 4 pin as out put.


    1. Make a input as high.
    2.scan 4 o/p pins continuously if any of them as high read the particular key.
    Just read the MikroC help or manual, It contain layout also.



  3. #3
    Advanced Member level 5
    Points: 35,652, Level: 46
    Tahmid's Avatar
    Join Date
    Jun 2008
    Location
    Cornell University, Ithaca, New York, USA (from Dhaka, Bangladesh)
    Posts
    4,730
    Helped
    1691 / 1691
    Points
    35,652
    Level
    46
    Blog Entries
    19

    Re: How to interface 4x4 Keypad with PIC microcontroller

    Hi,
    Take a look here:
    Help with keypad+lcd using 16F877A PIC in Mikrobasic
    Here you can find schematic with code using 16F877A.

    Hope this helps.
    Tahmid.



  4. #4
    Member level 2
    Points: 737, Level: 5
    bskumar7080's Avatar
    Join Date
    Feb 2010
    Location
    India
    Posts
    48
    Helped
    4 / 4
    Points
    737
    Level
    5

    Re: How to interface 4x4 Keypad with PIC microcontroller

    I am using MPLab IDE, did anyone have example keypad interfacing in MPlab


    3 members found this post helpful.

  5. #5
    Full Member level 3
    Points: 1,965, Level: 10

    Join Date
    Jan 2010
    Location
    kerala
    Posts
    155
    Helped
    55 / 55
    Points
    1,965
    Level
    10

    Re: How to interface 4x4 Keypad with PIC microcontroller

    Dear friend,

    Below program is for 4*1 keypad reading.


    list p=pic16f877a
    #include"p16f877a.inc"
    cblock 0x20
    r0,r1
    endc
    org00
    goto main
    org 04h
    retfie
    main
    bsf status,5
    bcf status,6
    movlw 0xf0
    movwf trisb
    movlw 0x00
    movwf trisc
    bcf status,5
    bsf portb,0

    top btfsc portb,4
    goto l1
    btfsc portb,5
    goto l2
    btfsc portb,6
    goto l3
    btfsc portb,7
    goto l4
    goto top

    l1 movlw 0x01
    movwf portc
    goto top
    l2 movlw 0x02
    movwf portc
    goto top
    l3 movlw 0x03
    movwf portc
    goto top
    l4 movlw 0x04
    movwf portc
    goto top
    last nop
    end



  6. #6
    Newbie level 3
    Points: 379, Level: 4

    Join Date
    Nov 2010
    Posts
    3
    Helped
    0 / 0
    Points
    379
    Level
    4

    Re: How to interface 4x4 Keypad with PIC microcontroller

    please 4*4 keypad by mplap



  7. #7
    Full Member level 3
    Points: 1,965, Level: 10

    Join Date
    Jan 2010
    Location
    kerala
    Posts
    155
    Helped
    55 / 55
    Points
    1,965
    Level
    10

    Re: How to interface 4x4 Keypad with PIC microcontroller

    Hai,

    Check above program.



  8. #8
    Newbie level 3
    Points: 379, Level: 4

    Join Date
    Nov 2010
    Posts
    3
    Helped
    0 / 0
    Points
    379
    Level
    4

    Re: How to interface 4x4 Keypad with PIC microcontroller

    ok but it is 4*1 & i need 4*4

    ---------- Post added at 12:45 ---------- Previous post was at 12:42 ----------

    can you help me to understand assemply program


    thanks

    ---------- Post added at 12:47 ---------- Previous post was at 12:45 ----------

    i don't understand this assemply program



    •   Alt9th December 2010, 17:17

      advertising

        
       

  9. #9
    Full Member level 3
    Points: 1,965, Level: 10

    Join Date
    Jan 2010
    Location
    kerala
    Posts
    155
    Helped
    55 / 55
    Points
    1,965
    Level
    10

    Re: How to interface 4x4 Keypad with PIC microcontroller

    Hai,

    1. Make four pin as input and four pin as out put. (movlw 0xf0) means 7-4 pins in portb as input and 0-3 are output pins
    2. Put a 1 at (bsf portb,0) IF you use 2*4 then set another portb pin like (bsf portb,1)etc...
    3. Check all the input pins ( btfsc portb,4 , btfsc portb, 5 btfsc portb, 6 btfsc portb,7)
    4. If any of them high print the corresponding value of key.

    Actually above program is used to scan only four keys
    So rest of them write yourself.


    1 members found this post helpful.

    •   Alt10th December 2010, 05:19

      advertising

        
       

  10. #10
    Member level 5
    Points: 337, Level: 3

    Join Date
    Aug 2010
    Location
    Batangas - Malvar
    Posts
    84
    Helped
    2 / 2
    Points
    337
    Level
    3

    Re: How to interface 4x4 Keypad with PIC microcontroller

    hi..
    how to use 4x3 keypad interfacing in zilog...thanks



  11. #11
    Junior Member level 1
    Points: 437, Level: 4

    Join Date
    Dec 2010
    Posts
    15
    Helped
    3 / 3
    Points
    437
    Level
    4

    Re: How to interface 4x4 Keypad with PIC microcontroller

    here is a procedure to read from keypad. in C language.

    satA...satD means the rows. and sut1...sut4 means columns.

    Code:
    #define satA P2_0
    #define satB P2_1
    #define satC P2_2
    #define satD P2_3
    #define sut1 P2_4
    #define sut2 P2_5
    #define sut3 P2_6
    #define sut4 P2_7
    
    char tus(void)
    {	
    	char don = ' ';	
    	 for (;;)
    	 {
    	   sut1=0;//1.sutunu kontrol et
    		while(!sut1)
    		{
    			while (satA==0) {while (satA==0) if(satA==1);don='1';}	   
    			while (satB==0) {while (satB==0) if(satB==1);don='4';}
    			while (satC==0) {while (satC==0) if(satC==1);don='7';}
    			while (satD==0) {while (satD==0) if(satD==1);don='C';}
    			sut1=1;  	
    		}
    	
    		sut2=0;//2.sutunu kontrol et
    		while(!sut2)
    		{
    			while (satA==0) {while (satA==0) if(satA==1);don='2';}
    			while (satB==0) {while (satB==0) if(satB==1);don='5';}
    			while (satC==0) {while (satC==0) if(satC==1);don='8';}
    			while (satD==0) {while (satD==0) if(satD==1);don='0';}
    			sut2=1;
    			
    		}
    		
    		sut3=0;//3.sutunu kontrol et
    		while(!sut3)
    		{
    			while (satA==0) {while (satA==0) if(satA==1);don='3';}
    			while (satB==0) {while (satB==0) if(satB==1);don='6';}
    			while (satC==0) {while (satC==0) if(satC==1);don='9';}
    			while (satD==0) {while (satD==0) if(satD==1);don='=';}
    			sut3=1;
    			
    		}
    		
    		sut4=0;//4.sutunu kontrol et
    		while(!sut4)
    		{
    			while (satA==0) {while (satA==0) if(satA==1);don='/';}
    			while (satB==0) {while (satB==0) if(satB==1);don='*';}
    			while (satC==0) {while (satC==0) if(satC==1);don='-';}
    			while (satD==0) {while (satD==0) if(satD==1);don='+';}
    			sut4=1;
    		}
    	  if(don != ' ') break;
    	  }
    	 
     	return don;
    }
    and here is the circuit for those codes.



    2 members found this post helpful.

  12. #12
    Member level 5
    Points: 337, Level: 3

    Join Date
    Aug 2010
    Location
    Batangas - Malvar
    Posts
    84
    Helped
    2 / 2
    Points
    337
    Level
    3

    Re: How to interface 4x4 Keypad with PIC microcontroller

    Quote Originally Posted by Th3r4p1sT View Post
    here is a procedure to read from keypad. in C language.

    satA...satD means the rows. and sut1...sut4 means columns.

    Code:
    #define satA P2_0
    #define satB P2_1
    #define satC P2_2
    #define satD P2_3
    #define sut1 P2_4
    #define sut2 P2_5
    #define sut3 P2_6
    #define sut4 P2_7
    
    char tus(void)
    {	
    	char don = ' ';	
    	 for (;;)
    	 {
    	   sut1=0;//1.sutunu kontrol et
    		while(!sut1)
    		{
    			while (satA==0) {while (satA==0) if(satA==1);don='1';}	   
    			while (satB==0) {while (satB==0) if(satB==1);don='4';}
    			while (satC==0) {while (satC==0) if(satC==1);don='7';}
    			while (satD==0) {while (satD==0) if(satD==1);don='C';}
    			sut1=1;  	
    		}
    	
    		sut2=0;//2.sutunu kontrol et
    		while(!sut2)
    		{
    			while (satA==0) {while (satA==0) if(satA==1);don='2';}
    			while (satB==0) {while (satB==0) if(satB==1);don='5';}
    			while (satC==0) {while (satC==0) if(satC==1);don='8';}
    			while (satD==0) {while (satD==0) if(satD==1);don='0';}
    			sut2=1;
    			
    		}
    		
    		sut3=0;//3.sutunu kontrol et
    		while(!sut3)
    		{
    			while (satA==0) {while (satA==0) if(satA==1);don='3';}
    			while (satB==0) {while (satB==0) if(satB==1);don='6';}
    			while (satC==0) {while (satC==0) if(satC==1);don='9';}
    			while (satD==0) {while (satD==0) if(satD==1);don='=';}
    			sut3=1;
    			
    		}
    		
    		sut4=0;//4.sutunu kontrol et
    		while(!sut4)
    		{
    			while (satA==0) {while (satA==0) if(satA==1);don='/';}
    			while (satB==0) {while (satB==0) if(satB==1);don='*';}
    			while (satC==0) {while (satC==0) if(satC==1);don='-';}
    			while (satD==0) {while (satD==0) if(satD==1);don='+';}
    			sut4=1;
    		}
    	  if(don != ' ') break;
    	  }
    	 
     	return don;
    }
    and here is the circuit for those codes.

    thanks....i have again a question..how the scrolling be done?example i pressed 1 in the keypad and i have 4 seven segment the output would be 0001 and if i pressed 2 the output woould be 0012..


    1 members found this post helpful.

  13. #13
    Junior Member level 1
    Points: 437, Level: 4

    Join Date
    Dec 2010
    Posts
    15
    Helped
    3 / 3
    Points
    437
    Level
    4

    Re: How to interface 4x4 Keypad with PIC microcontroller

    Quote Originally Posted by akoangsimula View Post
    thanks....i have again a question..how the scrolling be done?example i pressed 1 in the keypad and i have 4 seven segment the output would be 0001 and if i pressed 2 the output woould be 0012..
    u searching for c codes ? i can give some codes but i dont use pic. i use 8051 so they are not same.



  14. #14
    Member level 5
    Points: 337, Level: 3

    Join Date
    Aug 2010
    Location
    Batangas - Malvar
    Posts
    84
    Helped
    2 / 2
    Points
    337
    Level
    3

    Re: How to interface 4x4 Keypad with PIC microcontroller

    Quote Originally Posted by Th3r4p1sT View Post
    u searching for c codes ? i can give some codes but i dont use pic. i use 8051 so they are not same.
    i'm using zilog 6821 i'm not using pic...


    1 members found this post helpful.

  15. #15
    Junior Member level 1
    Points: 437, Level: 4

    Join Date
    Dec 2010
    Posts
    15
    Helped
    3 / 3
    Points
    437
    Level
    4

    Re: How to interface 4x4 Keypad with PIC microcontroller

    u told PIC at the head of this threat :D whatever its easy to scroll that numbers on displays. i explain sketchly. First u must have 4 output for drive 4 seven segment displays. (of course different number of outputs are usefull but easy one is this.) i called the displays as cikis0...cikis3

    Code:
    char cikis0 = 0x00, cikis1 = 0x00, cikis2 = 0x00, cikis3 = 0x00, giris;
    int sayac = 0;
    
    while(1)
    {
    	giris = tus(); //using the function i gave. it will wait until u press a button.
    	sayac++
    
    	if(sayac<5)
    	{
    	    cikis3 = cikis2;
    	    cikis2 = cikis1;
    	    cikis1 = cikis0;
    	    cikis0 = giris;
    	}else 
    	    {
    		sayac = 0;
    		cikis0 = 0x00;
    		cikis1 = 0x00;
    		cikis2 = 0x00;
    		cikis3 = 0x00;
    	    }
    }
    im sure there are many ideas about this. but mine is this :D


    1 members found this post helpful.

  16. #16
    Newbie level 1
    Points: 295, Level: 3

    Join Date
    May 2011
    Posts
    1
    Helped
    1 / 1
    Points
    295
    Level
    3

    Re: How to interface 4x4 Keypad with PIC microcontroller

    This is for Therapist.

    What compiler must be used for the c program you provided? since i tried compiling it in Hi-Tech ANSI C compiler and it just gave me a whole lot of errors. I im using the not so preferable compiler could you please refer me o one that you prefer.

    Thanks


    1 members found this post helpful.

  17. #17
    Full Member level 3
    Points: 1,965, Level: 10

    Join Date
    Jan 2010
    Location
    kerala
    Posts
    155
    Helped
    55 / 55
    Points
    1,965
    Level
    10

    Re: How to interface 4x4 Keypad with PIC microcontroller

    Hai,

    Use MikroC, it is simple and easy to use.


    1 members found this post helpful.

  18. #18
    Advanced Member level 3
    Points: 4,264, Level: 15
    PA3040's Avatar
    Join Date
    Aug 2011
    Posts
    756
    Helped
    32 / 32
    Points
    4,264
    Level
    15

    Re: How to interface 4x4 Keypad with PIC microcontroller

    Dear ansarmytheen ,
    can I have pseudocode for 4x4 keypad in assembly for pic
    thanks in advance



  19. #19
    Full Member level 3
    Points: 1,965, Level: 10

    Join Date
    Jan 2010
    Location
    kerala
    Posts
    155
    Helped
    55 / 55
    Points
    1,965
    Level
    10

    Re: How to interface 4x4 Keypad with PIC microcontroller

    Hai dear,

    Sorry for late. Yes, you can make code in assembly.



+ Post New Thread
Please login