0% found this document useful (0 votes)
26 views

Expt5 - Keyboard Programme

This document describes a program that scans a 4x4 keypad and displays the pressed key on a 7-segment display. It initializes ports and loads all 1s into P1 to enable row lines. It then checks each column line using JB instructions to detect pressed keys. When a key is pressed, it loads the corresponding digit from a lookup table into P2 to display on the 7-segment display.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views

Expt5 - Keyboard Programme

This document describes a program that scans a 4x4 keypad and displays the pressed key on a 7-segment display. It initializes ports and loads all 1s into P1 to enable row lines. It then checks each column line using JB instructions to detect pressed keys. When a key is pressed, it loads the corresponding digit from a lookup table into P2 to display on the 7-segment display.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

ORG 00H

MOV DPTR,#LUT // moves starting address of LUT to DPTR

MOV A,#11111111B // loads A with all 1's

MOV P2,#00000000B // initializes P0 as output port

BACK:MOV P1,#11111111B // loads P1 with all 1's

CLR P1.0 // makes row 1 low

JB P1.4,NEXT1 // checks whether column 1 is low and jumps to NEXT1 if not low

MOV A,#00D // loads a with 0D if column is low (that means key 1 is pressed)

ACALL DISPLAY // calls DISPLAY subroutine

NEXT1:JB P1.5,NEXT2 // checks whether column 2 is low and so on...

MOV A,#1D

ACALL DISPLAY

NEXT2:JB P1.6,NEXT3

MOV A,#2D

ACALL DISPLAY

NEXT3:JB P1.7,NEXT4

MOV A,#3D

ACALL DISPLAY

NEXT4:SETB P1.0

CLR P1.1

JB P1.4,NEXT5

MOV A,#4D

ACALL DISPLAY

NEXT5:JB P1.5,NEXT6

MOV A,#5D

ACALL DISPLAY

NEXT6:JB P1.6,NEXT7

MOV A,#6D

ACALL DISPLAY
NEXT7:JB P1.7,NEXT8

MOV A,#7D

ACALL DISPLAY

NEXT8:SETB P1.1

CLR P1.2

JB P1.4,NEXT9

MOV A,#8D

ACALL DISPLAY

NEXT9:JB P1.5,NEXT10

MOV A,#9D

ACALL DISPLAY

NEXT10:JB P1.6,NEXT11

MOV A,#10D

ACALL DISPLAY

NEXT11:JB P1.7,NEXT12

MOV A,#11D

ACALL DISPLAY

NEXT12:SETB P1.2

CLR P1.3

JB P1.4,NEXT13

MOV A,#12D

ACALL DISPLAY

NEXT13:JB P1.5,NEXT14

MOV A,#13D

ACALL DISPLAY

NEXT14:JB P1.6,NEXT15

MOV A,#14D

ACALL DISPLAY

NEXT15:JB P1.7,BACK
MOV A,#15D

ACALL DISPLAY

LJMP BACK

DISPLAY:MOVC A,@A+DPTR // gets digit drive pattern for the current key from LUT

MOV P2,A // puts corresponding digit drive pattern into P0

RET

LUT: DB 00000110B //1 Look up table starts here

DB 01011011B //2

DB 01001111B //3

DB 01110111B //a

DB 01100110B

DB 01101101B

DB 01111101B

DB 01111100B

DB 00000111B

DB 01111111B

DB 01101111B

DB 00111001B

DB 01111001B

DB 00111111B

DB 01110001B

DB 01011110B

END

You might also like