请问你有基于proteus仿真的单片机的交通灯的设计吗?最好是用C编写的程序! 10
2个回答
展开全部
ORG 0000H
MOV P0, #01111011B ;P0.7=P0.2=0, 东西 南北 都是红灯.
XRL P0, #255 ;取反,适合于高电平发光
CALL DL3S
LOOP:
MOV P0, #11011011B ;P0.5=P0.2=0, 南北绿 东西红.
XRL P0, #255
CALL DL15S
MOV P0, #10111011B ;P0.6=P0.2=0, 南北黄 东西红.
XRL P0, #255
CALL DL3S
MOV P0, #01111110B ;P0.7=P0.0=0, 南北红 东西绿.
XRL P0, #255
CALL DL15S
MOV P0, #01111101B ;P0.7=P0.1=0, 南北红 东西黄.
XRL P0, #255
CALL DL3S
SJMP LOOP
;--------------------------------------------
DL15S:
MOV R4, #5
DL2:
CALL DL3S
DJNZ R4, DL2
RET
;--------------------------------------------
DL3S: ;延时3s,实测3.03s
MOV R5, #23
DL3:
MOV R6, #0
DL4:
MOV R7, #0
DL5:
DJNZ R7, DL5
DJNZ R6, DL4
DJNZ R5, DL3
RET
END
MOV P0, #01111011B ;P0.7=P0.2=0, 东西 南北 都是红灯.
XRL P0, #255 ;取反,适合于高电平发光
CALL DL3S
LOOP:
MOV P0, #11011011B ;P0.5=P0.2=0, 南北绿 东西红.
XRL P0, #255
CALL DL15S
MOV P0, #10111011B ;P0.6=P0.2=0, 南北黄 东西红.
XRL P0, #255
CALL DL3S
MOV P0, #01111110B ;P0.7=P0.0=0, 南北红 东西绿.
XRL P0, #255
CALL DL15S
MOV P0, #01111101B ;P0.7=P0.1=0, 南北红 东西黄.
XRL P0, #255
CALL DL3S
SJMP LOOP
;--------------------------------------------
DL15S:
MOV R4, #5
DL2:
CALL DL3S
DJNZ R4, DL2
RET
;--------------------------------------------
DL3S: ;延时3s,实测3.03s
MOV R5, #23
DL3:
MOV R6, #0
DL4:
MOV R7, #0
DL5:
DJNZ R7, DL5
DJNZ R6, DL4
DJNZ R5, DL3
RET
END
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询