Interfacing of Keypad with 8051

Updated on 2017/08/08 19:10

Write introduction of the Article here.

Interfacing of Keypad with 8051

Interfacing Diagram

Hexadecimal-Keypad-interfacing-with-8051.png

ALP for the interfacing

Program:-Write an ALP to interface hexadecimal keypad with 8051 Microcontroller and display the pressed key on seven segment display( P1.0-P1.3 connected to rows and P2.0-P2.3 connected to columns)

ORG 0000h
MOV P2,#0FFH
Back1:MOV P1,#00H
MOV A,P2
ANL A,#00001111B
CJNE A,#00001111B,Back1
Back2:ACALL DELAY
MOV A,P2
ANL A,#00001111B
CJNE A,#00001111B,J1
SJMP Back2
J1:ACALL DELAY
MOV A,P2
ANL A,#00001111B
CJNE A,#00001111B,J2
SJMP Back2                 
J2:MOV P1,#11111110B
MOV A,P2
ANL A,#00001111B
CJNE A,#00001111B,ROW_1
MOV P1,#11111101B
MOV A,P2
ANL A,#00001111B
CJNE A,#00001111B,ROW_2
MOV P1,#11111011B
MOV A,P2
ANL A,#00001111B
CJNE A,#00001111B,ROW_3
MOV P1,#11110111B
MOV A,P2
ANL A,#00001111B
CJNE A,#00001111B,ROW_4
LJMP Back2
ROW_1:MOV DPTR,#FIRST
SJMP FIND
ROW_2:MOV DPTR,#SECOND
SJMP FIND
ROW_3:MOV DPTR,#THIRD
SJMP FIND
ROW_4:MOV DPTR,#FOURTH
SJMP FIND
FIND:RRC A
JNC MATCH
INC DPTR
SJMP FIND
MATCH:CLR A
MOVC A,@A+DPTR
MOV P0,A
LJMP Back1
ORG 300H
FIRST: DB '0','1','2','3'
SECOND: DB '4','5','6','7'
THIRD: DB '8','9','A','B'
FOURTH: DB 'C','D','E','F'
END

References

  • Created and developed by Prof S.M.Wagh & Prof. H. Lokhande, Sinhgad's NBNSTIC, Pune
  • WikiNote Foundation
Tags:
Created by Vishal E on 2017/08/04 12:45