你好,你有单片机交通灯设计程序和电路图吧?麻烦发到我邮箱744585214@qq.com,谢谢

2024-11-29 22:09:56
推荐回答(2个)
回答1:

发了,我的也是从网上下载的,你参考一下吧

回答2:

我这个程序是单片机十字路口的设计,你可以参考一下,这是我实训的时候做的。
#include "I2C.h"
#include "ZLG7290.h"
#include
sbit d=P2^7;
sbit c=P2^4;

/*
函数:Delay()
功能:延时10ms~655.36s
参数:
t>0时,延时(t*0.01)s
t=0时,延时655.36s
说明:
晶振采用11.0592MHz
*/
void Delay(unsigned int t)
{
do
{
TH0 = 0xD8;
TL0 = 0xf0;
TR0 = 1;
while ( !TF0 );
TF0 = 0;
TR0 = 0;
} while (--t);
}

main()
{ unsigned char x;
TMOD=0x01;
I2C_Init(); //等待ZLG7290复位完毕
Delay(30);
P2=0xdb;
for(x=5;x>0;x--) //状态0:延时4秒
{
ZLG7290_Download(4,0,0,x-1);
Delay(100);
}
P2=0x7b;
for(x=11;x>0;x--) //状态1:延时10秒
{
ZLG7290_Download(6,0,0,(x-1)%10);
ZLG7290_Download(7,0,0,(x-1)/10);
Delay(100);
}
for(x=7;x>0;x--)
{
ZLG7290_Download(6,0,0,x-1);
ZLG7290_Download(7,1,0,0);
d = d;
Delay(60);
d = ~d;
Delay(60);
}
P2=0xbb;
for(x=3;x>0;x--) //状态2:延时2秒
{
ZLG7290_Download(2,0,0,x-1);
Delay(100);
}

P2=0xdb;
for(x=2;x>0;x--) //状态3:延时1秒
{
ZLG7290_Download(0,0,0,x-1);
Delay(100);
}
P2=0xcf;
for(x=11;x>0;x--) //状态4:延时10秒
{
ZLG7290_Download(6,0,0,(x-1)%10);

ZLG7290_Download(7,0,0,(x-1)/10);
Delay(100);
}
for(x=7;x>0;x--)
{
ZLG7290_Download(6,0,0,x-1);
ZLG7290_Download(7,1,0,0);
c = c;
Delay(60);
c = ~c;
Delay(60);
}

P2=0xd7;
for(x=3;x>0;x--) //状态5:延时2秒
{
ZLG7290_Download(2,0,0,x-1);
Delay(100);
}

P2=0xdb;
for(x=2;x>0;x--) //状态6:延时1秒
{

ZLG7290_Download(0,0,0,x-1);
Delay(100);
}
light0();
Delay(500);
while(1);
{
}
}