E CÓ CODE MẠCH ĐÈN GIAO THÔNG LẤY TRÊN DIỄN ĐÀN NHƯ THẾ NÀY. E NHỜ AI SỬA MÔT CHÚT LÀM SAO CHO ĐÈN ĐỎ NHẤP NHÁY 1 VÀI S TRƯỚC KHI CHUYỂN SANG ĐÈN XANH ( như ở ngoài đường ấy ) Và cái thời gian code này chạy chậm hơn thời gian thực 1 ít ( 3s trong code = 4,5 s thực) . ai sửa hộ e cái. cần lắm. vì e ko biết về code.
DEM EQU R2
DEM1 EQU R3
DEM2 EQU R4
XANH EQU 16H
VANG EQU 17H
DO EQU 18H
ORG 000
JMP MAIN
ORG 0BH
MOV TH0,3CH
MOV TL0,0B0H
INC DEM
RETI
MAIN: MOV TMOD,#01
MOV TH0,#3CH
MOV TL0,#0B0H
CLR TF0
SETB TR0
MOV IE,#82H
TD: MOV P1,#21H
MOV XANH,#17
MOV VANG,#3
MOV DO,#20
MOV DEM1,XANH
MOV DEM2,DO
H1: MOV DEM,#0
LCALL BCD_HEX
LB1: LCALL HIEN_THI
CJNE DEM,#20,lb1
DEC DEM1
DEC DEM2
CJNE DEM1,#0,H1
MOV P1,#22H
MOV DEM1,VANG
H2: MOV DEM,#0
LCALL BCD_HEX
LB2: LCALL HIEN_THI
CJNE DEM,#20,LB2
DEC DEM1
DEC DEM2
CJNE DEM1,#-1,H2
MOV P1,#0CH
MOV DEM1,DO
MOV DEM2,XANH
H3: MOV DEM,#0
LCALL BCD_HEX
LB3: LCALL HIEN_THI
CJNE DEM,#20,LB3
DEC DEM1
DEC DEM2
CJNE DEM2,#0,H3
MOV P1,#14H
MOV DEM2,VANG
H4: MOV DEM,#0
LCALL BCD_HEX
LB4: LCALL HIEN_THI
CJNE DEM,#20,LB4
DEC DEM1
DEC DEM2
CJNE DEM2,#-1,H4
JMP TD
BCD_HEX:MOV A,DEM1
MOV B,#10
DIV AB
MOV 12H,A
MOV 13H,B
MOV A,DEM2
MOV B,#10
DIV AB
MOV 14H,A
MOV 15H,B
RET
HIEN_THI:MOV DPTR,#500H
MOV A,12H
MOVC A,@A+DPTR
MOV P2,A
MOV P3,#0FEH
LCALL DELAY
MOV P3,#0FFH
MOV A,13H
MOVC A,@A+DPTR
MOV P2,A
MOV P3,#0FDH
LCALL DELAY
MOV P3,#0FFH
MOV A,14H
MOVC A,@A+DPTR
MOV P2,A
MOV P3,#0FBH
LCALL DELAY
MOV P3,#0FFH
MOV A,15H
MOVC A,@A+DPTR
MOV P2,A
MOV P3,#0F7H
LCALL DELAY
MOV P3,#0FFH
DELAY: MOV R6,#150
DEL1: DJNZ R6,DEL1
RET
ORG 500H
DB 0C0H,0F9H,0A4H,0B0H,099H,092H,082H,0F8H,080H,090H
END
DEM EQU R2
DEM1 EQU R3
DEM2 EQU R4
XANH EQU 16H
VANG EQU 17H
DO EQU 18H
ORG 000
JMP MAIN
ORG 0BH
MOV TH0,3CH
MOV TL0,0B0H
INC DEM
RETI
MAIN: MOV TMOD,#01
MOV TH0,#3CH
MOV TL0,#0B0H
CLR TF0
SETB TR0
MOV IE,#82H
TD: MOV P1,#21H
MOV XANH,#17
MOV VANG,#3
MOV DO,#20
MOV DEM1,XANH
MOV DEM2,DO
H1: MOV DEM,#0
LCALL BCD_HEX
LB1: LCALL HIEN_THI
CJNE DEM,#20,lb1
DEC DEM1
DEC DEM2
CJNE DEM1,#0,H1
MOV P1,#22H
MOV DEM1,VANG
H2: MOV DEM,#0
LCALL BCD_HEX
LB2: LCALL HIEN_THI
CJNE DEM,#20,LB2
DEC DEM1
DEC DEM2
CJNE DEM1,#-1,H2
MOV P1,#0CH
MOV DEM1,DO
MOV DEM2,XANH
H3: MOV DEM,#0
LCALL BCD_HEX
LB3: LCALL HIEN_THI
CJNE DEM,#20,LB3
DEC DEM1
DEC DEM2
CJNE DEM2,#0,H3
MOV P1,#14H
MOV DEM2,VANG
H4: MOV DEM,#0
LCALL BCD_HEX
LB4: LCALL HIEN_THI
CJNE DEM,#20,LB4
DEC DEM1
DEC DEM2
CJNE DEM2,#-1,H4
JMP TD
BCD_HEX:MOV A,DEM1
MOV B,#10
DIV AB
MOV 12H,A
MOV 13H,B
MOV A,DEM2
MOV B,#10
DIV AB
MOV 14H,A
MOV 15H,B
RET
HIEN_THI:MOV DPTR,#500H
MOV A,12H
MOVC A,@A+DPTR
MOV P2,A
MOV P3,#0FEH
LCALL DELAY
MOV P3,#0FFH
MOV A,13H
MOVC A,@A+DPTR
MOV P2,A
MOV P3,#0FDH
LCALL DELAY
MOV P3,#0FFH
MOV A,14H
MOVC A,@A+DPTR
MOV P2,A
MOV P3,#0FBH
LCALL DELAY
MOV P3,#0FFH
MOV A,15H
MOVC A,@A+DPTR
MOV P2,A
MOV P3,#0F7H
LCALL DELAY
MOV P3,#0FFH
DELAY: MOV R6,#150
DEL1: DJNZ R6,DEL1
RET
ORG 500H
DB 0C0H,0F9H,0A4H,0B0H,099H,092H,082H,0F8H,080H,090H
END
Comment