-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMicrocontroller code
160 lines (135 loc) · 2.63 KB
/
Microcontroller code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# Microcontroller code:
ORG 00H
LJMP MAIN
ORG 300H
TBL: DB 0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H,80H,90H ;7seg data for comm. anode type
ORG 30H
MAIN: MOV P2,#00H
MOV P3,#00H
ACALL FRONT
MOV DPTR,#TBL
CLR A
MOV 40H,#10
MOV 43H,#10
MOV 46H,#20
MOV 49H,#20
MOV R0,#35
MOV R6,#30
MOV R7,#40
X1: MOV A,40H
MOV B,#10
DIV AB
MOV 41H,A
MOV 42H,B
A1: SETB P3.0
CLR P3.1
MOV A,41H
MOVC A,@A+DPTR
MOV P2,A
ACALL DELAY
MOV P3,#00H
SETB P3.1
CLR P3.0
MOV A,42H
MOVC A,@A+DPTR
MOV P2,A
ACALL DELAY
MOV P3,#00H
SJMP X3
X2: SJMP X1
X3: MOV A,43H
MOV B,#10
DIV AB
MOV 44H,A
MOV 45H,B
SETB P3.2
CLR P3.3
MOV A,44H
MOVC A,@A+DPTR
MOV P2,A
ACALL DELAY
MOV P3,#00H
SETB P3.3
CLR P3.2
MOV A,45H
MOVC A,@A+DPTR
MOV P2,A
ACALL DELAY
MOV P3,#00H
MOV A,46H
MOV B,#10
DIV AB
MOV 47H,A
MOV 48H,B
SETB P3.4
CLR P3.5
MOV A,47H
MOVC A,@A+DPTR
MOV P2,A
ACALL DELAY
MOV P3,#00H
SETB P3.5
CLR P3.4
MOV A,48H
MOVC A,@A+DPTR
MOV P2,A
ACALL DELAY
MOV P3,#00H
MOV A,49H
MOV B,#10
DIV AB
MOV 50H,A
MOV 51H,B
SETB P3.6
CLR P3.7
MOV A,50H
MOVC A,@A+DPTR
MOV P2,A
ACALL DELAY
MOV P3,#00H
SETB P3.7
CLR P3.6
MOV A,51H
MOVC A,@A+DPTR
MOV P2,A
ACALL DELAY
MOV P3,#00H
DJNZ R0,X2
MOV R0,#35
DJNZ 40H,Q1
MOV 40H,#20
Q1: DJNZ 43H,Q2
MOV 43H,#10
ACALL RIGHT
Q2: DJNZ 46H,Q3
MOV 43H,#20
MOV 46H,#10
Q3: DJNZ 49H,Q4
MOV 49H,#10
ACALL BACK
Q4: DJNZ R6,X4
ACALL LEFT
MOV 40H,#10
MOV 43H,#10
MOV 46H,#30
X4: DJNZ R7,L1
LJMP MAIN
L1: LJMP X1
DELAY: MOV R4,#5
H2: MOV R5,#0FFH
H1: DJNZ R5,H1
DJNZ R4,H2
RET
FRONT: MOV P1,#54H
MOV P0,#02H
RET
RIGHT: MOV P1,#0A1H
MOV P0,#02H
RET
BACK: MOV P1,#09H
MOV P0,#05H
RET
LEFT: MOV P1,#4AH
MOV P0,#08H
RET
##you just have copy and paste this code below