Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

C:\Users\VivoBook\OneDrive\Desktop\New folder (2)\mca3.

a51
1 //NAME AKSHAD DHAWAN
2 //GR NO. 21911172
3 //ROLL NO. 314007
4 //BATCH D1
5
6
7 lcd equ p3 ;lcd connected to point p3
8 en equ p2.7 ;enable connected to port p2.7
9 rw equ p2.6 ; read write connected to point p2.6
10 rs equ p2.5 ;register selected connected to port p2.7
11
12
13 org 0000h
14 acall delay
15 mov a,#38h ;to initialze the lcd as 8 bit data length
16 acall command ;call command subroutine
17
18 mov a,#0Eh ;to turn on display ,cursor blinking
19 acall command ; call command subroutine
20
21 mov a,#01h ;to clear display
22 acall command ; call command subroutine
23
24 mov a,#06h ; to shiftcursor to left for next character
25 acall command ;call jcommand subroutine
26
27 mov a,#80h ; to dispaly content from intial position on line 1
28 acall command ; call command subroutine
29
30
31 mov a,#'A' ; load ASCII value of 'R' in the accumalator
32 acall display ;call command subroutine
33
34 mov a,#'K' ; load ASCII value of 'R' in the accumalator
35 acall display ;call command subroutine
36
37 mov a,#'S' ; load ASCII value of 'R' in the accumalator
38 acall display ;call command subroutine
39
40 mov a,#'H' ; load ASCII value of 'R' in the accumalator
41 acall display ;call command subroutine
42
43 mov a,#'A' ; load ASCII value of 'R' in the accumalator
44 acall display ;call command subroutine
45
46 mov a,#'D' ; load ASCII value of 'R' in the accumalator
47 acall display ;call command subroutine
48
49
50 mov a, # 0c0h ; to diaplay the content in the second line;
51 acall command ;to call command subroutine
52 acall delay ;to call delay
53
54 mov a,#'R' ; load ASCII value of 'R' in the accumalator
55 acall display ;call command subroutine
56
57 mov a,#'O' ; load ASCII value of 'R' in the accumalator
58 acall display ;call command subroutine
59
60 mov a,#'L' ; load ASCII value of 'R' in the accumalator
61 acall display ;call command subroutine
62
63 mov a,#'L' ; load ASCII value of 'R' in the accumalator
64 acall display ;call command subroutine
65
66 mov a,#'N' ; load ASCII value of 'R' in the accumalator
67 acall display ;call command subroutine
68
69 mov a,#'0' ; load ASCII value of 'R' in the accumalator
70 acall display ;call command subroutine
71
72 mov a,#':' ; load ASCII value of 'R' in the accumalator

Page 1
C:\Users\VivoBook\OneDrive\Desktop\New folder (2)\mca3.a51
73 acall display ;call command subroutine
74
75 mov P0,#0fh ;po.7 to p0.4 output (row) and p0.3 to p0.0 input(coloumn)
76
77 K1:
78 mov P0,#0fh ;ground all rows at onece and second 1 to aLL coloumn
79 mov a,P0 ; ready all the coloumn
80 anl a,#0fh ;mask unused bits
81 mov P0,a
82 mov a,P0
83 anl a,#0fh
84 cjne a,#0fh,k1
85
86 K2:
87 acall delay
88 mov a,P0 ;see if any key is pressed
89 anl a,#0fh ;mask unused bits
90 cjne a,#0fh,over ;over key pressed await closure
91 sjmp K2 ;check if key pressed
92
93
94 over:
95 acall delay
96 mov a,P0 ;check key closure
97 anl a,#0fh ;mask unused bits
98 cjne a,#0fh ,over1 ;key pressed finds rows
99 sjmp K2
100
101 over1:
102 clr P0.4
103 setb P0.5
104 setb P0.6
105 setb P0.7
106 mov a,P0
107 anl a, #0fh
108 cjne a,#0fh,ROW1 ;key row 1,find column
109
110 clr P0.5
111 setb P0.7
112 setb P0.6
113 setb P0.4
114 mov a,P0
115 anl a,#0fh
116 cjne a,#0fh,ROW2 ;KEY ROW 2,FIND COLOMN
117
118 clr P0.6
119 setb P0.7
120 setb P0.5
121 setb P0.4
122 mov a,P0
123 anl a,#0fh
124 cjne a,#0fh,ROW3 ;KEY ROW 2,FIND COLOMN
125
126 clr P0.7
127 setb P0.4
128 setb P0.6
129 setb P0.5
130 mov a,P0
131 anl a,#0fh
132 cjne a,#0fh,ROW4 ;KEY ROW 2,FIND COLOMN
133 sjmp K2
134 mov r0,#04h
135
136
137 ROW1:
138 MOV DPTR,#KCODE0;DPTR = POINTER
139 SJMP FIND
140
141 ROW2:
142 MOV DPTR,#KCODE1
143 SJMP FIND
144

Page 2
C:\Users\VivoBook\OneDrive\Desktop\New folder (2)\mca3.a51
145 ROW3:
146 MOV DPTR,#KCODE2
147 SJMP FIND
148
149
150 ROW4:
151 MOV DPTR,#KCODE3
152
153
154
155
156 FIND:
157 RRC A
158 JNC MATCH
159 INC DPTR
160 djnz r0,FIND
161
162
163
164 MATCH:
165 CLR A
166 movc A,@A+DPTR
167 acall display
168 LJMP K1
169
170
171
172
173
174 command: acall delay
175 mov lcd ,a
176 clr rs
177 clr rw
178 setb en
179 acall delay
180 clr en
181 ret
182
183
184
185
186
187 display: acall delay
188 mov lcd ,a
189 setb rs
190 clr rw
191 setb en
192 acall delay
193 clr en
194 ret
195
196
197 delay: mov r3,#255
198 here2: mov r4,#255
199 here3: djnz r4,here3
200 djnz r3,here2
201 ret
202
203
204 KCODE0: DB'0','1','2','3'
205 KCODE1: DB'4','5','6','7'
206 KCODE2: DB'8','9','A','B'
207 KCODE3: DB'C','D','E','F'
208 END
209

Page 3

You might also like