1. You can now buy finished microcontroller project from us, Check out the Store for the complete list of projects.
  2. Need a custom project, Send us some details about your project. So that we can quote the price for it.

8051 4x4 keypad interface with 7segment display 1.0

Interfacing 4x4 matrix keypad with 8051 microcontroller and 7segment display.

  1. sajiv jess
    Interfacing 4x4 matrix keypad with 8051 microcontroller and 7segment display.
    Download contains the source code with proteus simulation file.

    Sponsored Links

    Circuit Diagram
    [​IMG]

    C code
    Code (C):
    1. #include <reg51.h>
    2. #include <stdio.h>
    3.  
    4. #define byte unsigned char
    5.  
    6. //Interrupt service routine
    7. void keyinterrupt()  interrupt 2
    8. {
    9.     int t;
    10.     byte keycode,scancode,flag=0xff;
    11.     t=5000;
    12.     while(t--);
    13.     if(INT1==1)
    14.         return;
    15.     EX1=0;
    16.     scancode=0xef;
    17.     while(scancode!=0xff)
    18.     {
    19.         P1=scancode;
    20.         keycode=P1;
    21.         if((keycode&0x0f)!=0x0f)
    22.             break;
    23.         scancode=(keycode<<1)|0x0f;
    24.     }
    25.     keycode=~keycode;
    26.  
    27.     P2=keycode; //Will scan the code output, digital control with digital control functions with the decoding
    28.     P1=0X0F;
    29.     while(1)
    30.     {
    31.         if(INT1==1)
    32.         {
    33.             flag=~flag;
    34.             if(flag==0)
    35.             break;
    36.         }
    37.         t=10000;
    38.         while(t--);
    39.     }
    40.     EX1=1;
    41.     return;
    42. }
    43.  
    44. void main(void)
    45. {  
    46.     IE=0;
    47.     EX1=1;
    48.     EA=1;  //Break open
    49.     P2=0XFF;
    50.     P1=0X0F;
    51.     while(1)
    52.     {      
    53.     }                
    54. }
Loading...