欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標(biāo)題:
使用單片機(jī)定時(shí)器控制交通燈設(shè)計(jì)
[打印本頁(yè)]
作者:
周春雨0321
時(shí)間:
2018-12-10 09:27
標(biāo)題:
使用單片機(jī)定時(shí)器控制交通燈設(shè)計(jì)
這是我課程設(shè)計(jì)需要的源代碼和原理圖,發(fā)給大家
0.png
(12.6 KB, 下載次數(shù): 24)
下載附件
2018-12-10 15:58 上傳
單片機(jī)源程序如下:
#include <reg51.h>
#define SEG P2
#define SCANP P1
#define count_M1 50000
#define TH_M1 (65535-count_M1)/256;
#define TL_M1 (65535-count_M1)%256;
int count_T0=0;
#define count_M2 250
#define TH_M2 (256-count_M2)
#define TL_M2 (256-count_M2)
char count_T1=0;
char code TAB[10]={0xc0,0xf9,0xa4,0xb0,0x99,
0x92,0x82,0xf8,0x80,0x98};
char disp[2]={0x82,0xc0};
bit red,green,yellow,turnred; //定義紅綠黃燈的標(biāo)志位
char scan=0;
sbit hong=P3^2;
sbit huang=P3^1;
sbit lv=P3^0;
main()
{
IE=0x8a;
TMOD=0x21;
TH0=TH_M1;TL0=TL_M1;
TR0=1;
TH1=TH_M2;TL1=TL_M2;
TR1=1;
red=1;
green=0;
yellow=0;
hong=0;
while(1);
}
void delay()
{
unsigned char a,b;
for(a=100;a>0;a--)
for(b=255;b>0;b--);
}
void TO_1s(void)interrupt 1
{
static char seconds = 60;
TH0=TH_M1;TL0=TL_M1;
if(++count_T0==20)
{
count_T0=0;
seconds--;
if(seconds==0)
{if(red==1&green==0&yellow==0)
{red=0;
green=1;
yellow=0;
hong=1;
lv=0;
seconds=30;
delay();
}
else if(red==0&green==1&yellow==0)
{
green=0;
red=0;
yellow=1;
lv=1;
huang=0;
seconds=3;
delay();
}
else if(red==0&green==0&yellow==1)
{
red=1;
green=0;
yellow=0;
hong=0;
huang=1;
seconds=60;
delay();
}
}
disp[1]=TAB[seconds%10];
disp[0]=TAB[seconds/10];
}
}
void T1_8ms(void)interrupt 3
{
if(++count_T1==32)
{
count_T1=0;
if(++scan==3)scan=1;
SEG=0xff;
SCANP=~scan;
SEG=disp[scan-1];
}
}
復(fù)制代碼
所有資料51hei提供下載:
使用定時(shí)器的交通燈.rar
(26.51 KB, 下載次數(shù): 12)
2018-12-10 09:27 上傳
點(diǎn)擊文件名下載附件
下載積分: 黑幣 -5
歡迎光臨 (http://m.raoushi.com/bbs/)
Powered by Discuz! X3.1