ORG 0H
JMP START
start:
cek1: jb p1.0,cek2
mov r4,#225
c1: djnz r4,c1
call nyala
cek2: jb p1.1,cek3
mov r4,#225
c2: djnz r4,c2
call mati
sjmp start
;==============================
;SUBROUTINE UNTUK NYALA
;==============================
NYALA: clr P0.0
setb p0.1
setb P0.2
clr P2.3
setb p2.6
setb P2.5
clr P0.3
setb p0.4
setb P0.5
setb P2.0
setb p2.1
clr P2.2
call delay
call delay
SETB P0.0
CLR p0.1
setb P0.2
SETB P2.3
CLR p2.6
setb P2.5
SETB P0.3
CLR p0.4
setb P0.5
setb P2.0
CLR p2.1
SETB P2.2
call delay
SETB P0.0
setb p0.1
CLR P0.2
SETB P2.3
SETB p2.6
CLR P2.5
SETB P0.3
setb p0.4
CLR P0.5
CLR P2.0
setb p2.1
SETB P2.2
call delay
call delay
SETB P0.0
CLR p0.1
setb P0.2
SETB P2.3
CLR p2.6
setb P2.5
SETB P0.3
CLR p0.4
setb P0.5
setb P2.0
CLR p2.1
SETB P2.2
CALL DELAY
LJMP start
BACK2: RET
;========================================
;SUBROUTINE UNTUK MEMATIKAN TRAFFIC LIGHT
;========================================
mati: setb p2.0
setb p2.1
setb p2.2
setb p2.3
setb p2.4
setb p2.5
setb p0.0
setb p0.1
setb p0.2
setb p0.3
setb p0.4
setb p0.5
setb p0.6
setb p0.7
call delay
ljmp start
back4: ret
;=================
;SUBROUTINE DELAY
;=================
DELAY: MOV R1,#25
DELAY1: MOV R2,#180
DELAY2: MOV R3,#225
DELAY3: DJNZ R3,DELAY3
DJNZ R2,DELAY2
DJNZ R1,DELAY1
RET
END
Tidak ada komentar:
Posting Komentar