//Production: Xiaojun
# include & ltreg52.h & gt
# Defined on 1
# Define Close 0
Unsigned int t, t _ Light
Unsigned character symbol;
sbit sn_green=p 1^0;
sbit sn_yellow=p 1^ 1;
sbit sn_red=p 1^2;
sbit ew_green=p 1^3;
sbit ew_yellow=p 1^4;
sbit ew_red=p 1^5;
Void initialization (void)
{
TMOD = 0x 0 1;
EA = 1;
ET0 = 1;
TR0 = 1;
TH0 =(65536-50000)/256;
TL0 =(65536-50000)% 256;
}
Invalid master (invalid)
{
init();
while( 1)
{
Switch (sign)
{
Case 1:
SN _ Green = ON
SN _ Yellow = OFF
SN _ Red = OFF
EW _ Green = OFF
EW _ Yellow = OFF
EW _ Red = on;
Break;
Case 2:
SN _ Green = OFF
SN _ Yellow = on;
SN _ Red = OFF
EW _ Green = OFF
EW _ Yellow = on;
EW _ Red = OFF
Break;
Case 3:
SN _ Green = OFF
SN _ Yellow = OFF
SN _ Red = ON
EW _ Green = on;
EW _ Yellow = OFF
EW _ Red = OFF
Break;
}
}
}
Invalid timer (void) interrupt 1 use 0
{
TH0 =(65536-50000)/256;
TL0 =(65536-50000)% 256;
t++;
If (t== 18)
{
t = 0;
t _ light++;
if(t _ Light & lt; =30)
{
flag = 1;
}
else if(t _ Light & lt; =34)
{
flag = 2;
}
else if(t _ Light & lt; 88)
{
flag = 3;
if(t _ Light = = 88)t _ Light = 0;
}
}
}