Professional Documents
Culture Documents
Code
Code
org 0000h
mov p1,#0ffh
mov p3,#0ffh
mov p2,#0ffh
main:mov a,p2 ;if congestion is on 4th side then only green time will be double jump to aa1
cjne a,#0ffh,aa1 ;normal traffic
sjmp aa11
aa1:cjne a,#0fch,aa2
sjmp congst
aa2:jb p2.2,main
sjmp ambul
aa11:
mov p1,#9eh
mov p3,#0f7h
acall delay
mov p3,#0fbh
mov p1,#0aeh
acall delay
mov p3,#0fch
mov p1,#0f3h
;congestion
acall delay
mov p3,#0fdh
mov p1,#75h
acall delay
sjmp main
congst:
mov p1,#9eh
mov p3,#0f7h
acall delay
acall delay
acall delay
mov p3,#0fbh
mov p1,#0aeh
acall delay
mov p3,#0fch
mov p1,#0f3h
acall delay
mov p3,#0fdh
mov p1,#75h
acall delay
sjmp main
ambul:mov p3,#0f7h
mov p1,#0b6h
jb p2.2,main
sjmp ambul
delay:MOV R3,#22
MOV R2,#24
MOV R1,#206
TT1: DJNZ R1,TT1
DJNZ R2,TT1
DJNZ R3,TT1
RET
end