{
P1=State[2]; //SN左拐绿灯亮,EW红灯 ShuMa_Display(); }
P1=0xFF;
while(Time_SN>=0) { Flag_SN_Yellow=1; //SN开黄灯信号位 Flag_EW_Yellow=1; ShuMa_Display(); }
}
void state3() {
/***********赋值*********/ EW=EW1; SN=SN1; EWL=EWL1; SNL=SNL1;
/*******SN禁止,EW通行状态**********/
SN_ManRed=0; //SN人行道禁止 SN_ManGreen=1; EW_ManRed=1;
EW_ManGreen=0; //EW人行道通行 Flag_SN_Yellow=0; //SN关黄灯显示信号 Flag_EW_Yellow=0;//EW关黄灯显示信号 Time_EW=SN; Time_SN=EW;
while(Time_EW>=5)
{ P1=State[4];//EW通行,SN红灯 ShuMa_Display(); }
P1=0Xff;
while(Time_EW>=0) { Flag_EW_Yellow=1;//EW开黄灯信号位 SN_Red=0;
//P1=P1|0x0B; //保持SN红灯
ShuMa_Display(); } }
void state4() {
/***********EW方向左拐状态**************/ SN_ManRed=0; //SN人行道禁止 SN_ManGreen=1; EW_ManRed=0; //EW人行道禁止
EW_ManGreen=1;
Flag_SN_Yellow=0; //SN关黄灯显示信号 Flag_EW_Yellow=0;//EW关黄灯显示信号 Time_EW=EWL; while(Time_EW>=5) { P1=State[6]; //EW左拐绿灯亮,SN红灯 ShuMa_Display(); }
P1=0Xff;
while(Time_EW>=0) { Flag_EW_Yellow=1; //EN开黄灯信号位 Flag_SN_Yellow=1; ShuMa_Display(); } /***********赋值*********/ EW=EW1; SN=SN1;
EWL=EWL1;
SNL=SNL1; }
/****************定时器0初始化函数***************/ void timer0_init() {
TMOD=0x01; //定时器0工作方式1
TH0=(65536-10000)/256; //装初值
TL0=(65536-10000)%6; EA=1; //开总中断
ET0=1;//开定时器0中断 TR0=1;//启动定时器 }
/*******************定时器0服务中断函数***********/ void timer() interrupt 1 {
uchar t; TH0=(65536-50000)/256; TL0=(65536-50000)%6; t++; if(shezhi1==0) { EW1=60; SN1=40; EWL1=19; SNL1=19;
write(10,60); //24C02写操作 write(11,40); write(12,19); write(13,19); }
if(shezhi2==0) { EW1=50; SN1=40; EWL1=9; SNL1=9; //write(10,60); //write(11,50); //write(12,9); //write(13,9); }
if(stop1==0) {
P0=table[0];
EW_ShuMa2=0; EW_ShuMa1=0; SN_ShuMa2=0; SN_ShuMa1=0; P1=0XBB;
EW_ManGreen=1; SN_ManGreen=1; EW_ManRed=0; SN_ManRed=0; while(1);
}
if(t==10) { if(Flag_SN_Yellow==1) //测试南北黄灯标志位 {SN_Yellow=~SN_Yellow;} if(Flag_EW_Yellow==1) //测试东西黄灯标志位 {EW_Yellow=~EW_Yellow;}
} if(t==20) { Time_EW--; Time_SN--; if(Flag_SN_Yellow==1) //测试南北黄灯标志位 { SN_Yellow=~SN_Yellow; }
if(Flag_EW_Yellow==1) //测试东西黄灯标志位 { EW_Yellow=~EW_Yellow; } t=0; } }
24c02的.h程序
#define uchar unsigned char