www.pudn.com > traffic.rar > Text1.c, change:2008-03-12,size:816b


#include 
#include 
#include 
sbit Sred_Egeeen=P1^1;  
sbit Syellow_Eyellow=P1^2; 
sbit Sgreen_Ered=P1^3;//定义南北、东西向端口 
void delay(unsigned char k);//函数声明 
unsigned char count;//定义全局变量 
void time0_int(void) interrupt 1 
  { 
    count=count+1; 
				 } 
 
void main(void) 
{  
  TMOD=0X00;//工作方式0 8.192ms 
  TH0=0X00; 
  TL0=0X00; 
  EA=1; 
  ET0=1; 
  TR0=1; 
  while(1) 
  { 
    count=0; 
    Sred_Egeeen=0; 
	 Syellow_Eyellow=1; 
	 Sgreen_Ered=1; 
    do{;} 
	 while(count<=250);//南北红灯,东西绿灯 
	 Sred_Egeeen=1; 
	 Syellow_Eyellow=0; 
	 Sgreen_Ered=1; 
	 count=0; 
	 do{;} 
    while(count<=40);//黄灯切换 
    Sred_Egeeen=1; 
	 Syellow_Eyellow=1; 
	 Sgreen_Ered=0; 
	 count=0; 
	 do{;} 
    while(count<=250);//南北绿灯,东西红灯*/ 
	 power=1; 
	 } 
	}