交通灯Word下载.docx

上传人:b****6 文档编号:19159239 上传时间:2023-01-04 格式:DOCX 页数:13 大小:16.84KB
下载 相关 举报
交通灯Word下载.docx_第1页
第1页 / 共13页
交通灯Word下载.docx_第2页
第2页 / 共13页
交通灯Word下载.docx_第3页
第3页 / 共13页
交通灯Word下载.docx_第4页
第4页 / 共13页
交通灯Word下载.docx_第5页
第5页 / 共13页
点击查看更多>>
下载资源
资源描述

交通灯Word下载.docx

《交通灯Word下载.docx》由会员分享,可在线阅读,更多相关《交通灯Word下载.docx(13页珍藏版)》请在冰豆网上搜索。

交通灯Word下载.docx

#defineucharunsignedchar

#defineuintunsignedint

#defineN35

sfrP1M1=0x91;

sfrP1M0=0x92;

sbita=P0^5;

sbitb=P0^6;

sbitc=P0^7;

sbitd=P3^6;

sbite=P3^7;

ucharcodetable1[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,

0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};

ucharcodetable2[]={0xfe,0xfd,0xfb,0xf7};

ucharshu[]={0,0,0,0};

ucharcount,t,n,flag,flag1=1;

uinttemp1,temp2,temp3,temp4,temp;

voiddelay(uintx);

voiddisplay();

voidzhuangtai1();

voidzhuangtai2();

voidzhuangtai3();

voidzhuangtai4();

voidanjian();

voiddelay(uintx)

{

uinti,j;

for(i=0;

i<

x;

i++)

for(j=110;

j>

0;

j--);

}

voiddisplay()

uchari;

shu[0]=temp/1000;

shu[1]=temp%1000/100;

shu[2]=temp%100/10;

shu[3]=temp%10;

4;

{

P1=table1[shu[i]];

P0=table2[i];

delay(10);

}

}

voidzhuangtai1()

flag=1;

temp1=60;

TMOD=0x01;

TH0=(65536-46070)/256;

TL0=(65536-46070)%256;

EA=1;

ET0=1;

TR0=1;

while

(1)

if(flag1==1)

{

temp=temp1;

P2=0x9e;

P3=0xdf;

display();

if(count==20)

count=0;

temp1--;

if(temp1==-1)

{

temp1=60;

flag=0;

break;

}

}

else

if(n==1)

P2=0xdb;

P3=0xdb;

}

anjian();

}

voidzhuangtai2()

flag=2;

temp2=5;

temp=temp2;

P2=0x5d;

temp2--;

if(temp2==-1)

temp2=5;

voidzhuangtai3()

flag=3;

temp3=40;

temp=temp3;

P2=0xf3;

P3=0xf3;

temp3--;

if(temp3==-1)

temp3=40;

voidzhuangtai4()

flag=4;

temp4=5;

temp=temp4;

P2=0xeb;

P3=0xeb;

temp4--;

if(temp4==-1)

temp4=5;

voidanjian()

d=0;

if(a==0)

for(i=0;

N;

i++)

display();

}

if(a==0)

while(!

a);

flag1=1;

t++;

if(t==1)

{

TR0=0;

display();

if(t==2)

t=0;

TR0=1;

if(t!

=0)

if(b==0)

for(i=0;

if(b==0)

while(!

b);

if(t==1)

{

display();

switch(flag)

{

case1:

temp1++;

if(temp1==60)

temp1=0;

break;

case2:

temp2++;

if(temp2==5)

temp2=0;

case3:

temp3++;

if(temp3==40)

temp3=0;

case4:

temp4++;

if(temp4==5)

temp4=0;

}

}

if(c==0)

if(c==0)

c);

if(t==1)

temp1--;

if(temp1==-1)

temp1=60;

temp2--;

if(temp2==-1)

temp2=5;

temp3--;

if(temp3==-1)

temp3=40;

temp4--;

if(temp4==-1)

temp4=5;

e=0;

flag1=0;

n++;

if(n==2)

n=0;

flag1=1;

voidmain()

P1M1=0;

P1M0=0xff;

zhuangtai1();

zhuangtai2();

zhuangtai3();

zhuangtai4();

voidtimer0()interrupt1

TH0=(65536-46070)/256;

count++;

五、实验过程中遇到的问题及解决方法

1.刚开始实验时,在各路口红绿黄灯转换上有大问题,该亮的不亮,该灭的

不灭,经过仔细检查,调试,实现了各色灯的正常运行。

2.原本想让黄灯是出现闪烁效果的,但是发现数码管闪烁效果不好,所以最

后没有用闪烁。

3.紧急情况按下4键,再按下不会恢复,后来通过仔细检查,调试,实现了

按下后恢复。

 

指导老师签字:

日期:

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 工程科技 > 兵器核科学

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1