#include
bit red,green,yellow,turnred; //定义红、黄、绿及转红标志
code unsigned char tab[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,
0x7f,0x6f}; //共阴极数码管码表
#define LIGHT P0
#define SEG P1
#define BITR P2
unsigned char Dis_Shiwei;//定义十位
unsigned char Dis_Gewei; //定义个位
unsigned char second,count=0; //初值60
#define uchar unsigned char
#define uint unsigned int
sbit add=P3^3; //定义东西绿灯时间加按键
sbit sub=P3^4; //定义东西绿灯时间减按键
sbit K1=P3^1; //定义设定时间按键
sbit add2=P3^5; //定义调南北绿灯时间加按键
sbit sub2=P3^6; //定义调南北绿灯时间减按键
unsigned char timeDX=13,timeNB=15; //定义东西和南北绿灯亮时可调变量并赋予初值2S
void delay(unsigned int cnt) //用于动态扫描数码管的延时程序
{
while(--cnt);
}
/*********************************延时子程序*************************************/
void DelayMS(unsigned int x) //延时ms
{
unsigned char t;
while(x--)
{
for(t=120;t>