新聞中心

EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 51模擬交通燈實(shí)驗(yàn)

51模擬交通燈實(shí)驗(yàn)

作者: 時(shí)間:2016-11-17 來源:網(wǎng)絡(luò) 收藏
C代碼:

#include51.h>
/*************延時(shí)子程序*******************************/
void delay(unsigned int x)//最小1毫秒
{
unsigned char j;
while(x--)
{
for(j=0;j<125;j++)
{;}
}
}
void main(void)
{
unsigned char i;
do
{
P0_0=1;
P0_1=1;
P0_2=0;
P0_3=0;
P0_4=1;
P0_5=1;
delay(1000);
for(i=0;i<5;i++)
{
P0_0=1;
P0_1=0;
P0_2=1;
P0_3=0;
P0_4=1;
P0_5=1;
delay(100);
P0_0=1;
P0_1=1;
P0_2=1;
P0_3=0;
P0_4=1;
P0_5=1;;
delay(100);
}
P0_0=0;
P0_1=1;
P0_2=1;
P0_3=1;
P0_4=1;
P0_5=0;
delay(1000);
for(i=0;i<5;i++)
{
P0_0=0;
P0_1=1;
P0_2=1;
P0_3=1;
P0_4=0;
P0_5=1;
delay(100);
P0_0=0;
P0_1=1;
P0_2=1;
P0_3=1;
P0_4=1;
P0_5=1;
delay(100);
}
}
while(1);
}

本文引用地址:http://butianyuan.cn/article/201611/315522.htm

仿真電路



關(guān)鍵詞: 51模擬交通

評(píng)論


技術(shù)專區(qū)

關(guān)閉