这个交通灯程序每段的大体意思是什么呀 求指点
#include<reg51.h>#include<intrins.h>
sbit smg1=P3^0;
sbit smg2=P3^1;
sbit N_green=P2^0;
sbit N_red=P2^1;
sbit N_yellow=P2^2;
sbit S_green=P2^7;
sbit S_red=P2^6;
sbit S_yellow=P2^5;
sbit W_green=P1^0;
sbit W_red=P1^1;
sbit W_yellow=P1^2;
sbit E_green=P1^7;
sbit E_red=P1^6;
sbit E_yellow=P1^5;
int djs=30,js=0,bt=30; //djs和bt是初始倒计时时间,可修改
//int table[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
int table[]={0x3f,0x06,0x5b,0x4f, 0x66,0x6d,0x7d,0x07, 0x7f,0x6f,0x40};
void jtd();
void djsxs();
void delayms(int x)
{
char i;
while(x--)
{
for(i=150;i>0;i--);
}
}
setxs()
{
int b1,b2;
b1=djs/10;
b2=djs%10;
P0=table[b1];
smg1=0;
delayms(3);
smg1=1;
P0=table[b2];
smg2=0;
delayms(3);
smg2=1;
}
void delayms2(int p)
{
char i;
while(p--)
{ setxs();
for(i=150;i>0;i--)
setxs();
}
}
Timer0_init()
{
js=0;
TMOD=0x01; //T0为定时器方式1
TH0=0x4c;
TL0=0x00;
TR0=1;//IT1=1;
ET0=1;//EX1=1;
EA=1;
}
void timer0() interrupt 1 using 1
{
TF0=0;
TH0=0x4c;
TL0=0x00;
js++;
if(js==20)
{ js=0;
djs--;
//led1=~led1;
}
}
void djsxs()
{ int b1,b2;
b1=djs/10;
b2=djs%10;
P0=table[b1];
smg1=0;
delayms(3);
smg1=1;
P0=table[b2];
smg2=0;
delayms(3);
smg2=1;
}
void jtd()
{
int tp=1;
while(1)
{
tp=1;
djsxs();
if(djs>5)
//次数djs>5 djs<5表示倒计时等于5时开始亮黄灯
//以下四次都要修改
{
W_red=0;
E_red=0;
N_green=0;
S_green=0;
}
if(djs<=5)
{
N_green=1;
S_green=1;
N_yellow=0;
S_yellow=0;
}
if(djs==0)
{
djs=bt;
while(tp)
{
djsxs();
if(djs>5)
{
W_red=1;
E_red=1;
W_green=0;
E_green=0;
N_yellow=1;
S_yellow=1;
N_red=0;
S_red=0;
}
if(djs<=5)
{
W_green=1;
E_green=1;
W_yellow=0;
E_yellow=0;
}
if(djs==0)
{
djs=bt;
N_red=1;
S_red=1;
W_yellow=1;
E_yellow=1;
tp=0;
}
}
}
}
}
main()
{
Timer0_init();
W_red=1;
E_red=1;
W_green=1;
E_green=1;
W_yellow=1;
E_yellow=1;
N_green=1;
S_green=1;
N_yellow=1;
S_yellow=1;
N_red=0;
S_red=0;
jtd();