/* 名称:10s 的秒表
说明:首次按键计时开始,再次按键暂停,第三次按键清零。
*/
#include
#define uchar unsigned char
#define uint unsigned int
sbit K1=P3^7;
uchar
i,Second_Counts,Key_Flag_Idx;
bit Key_State;
uchar
DSY_CODE[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
//延时
void DelayMS(uint ms)
{
uchar t;
while(ms--) for(t=0;t<120;t++);
}
//处理按键事件
void Key_Event_Handle()
{
if(Key_State==0)
{
Key_Flag_Idx=(Key_Flag_Idx+1)%3;
switch(Key_Flag_Idx)
{
case 1:EA=1;ET0=1;TR0=1;break;
case 2:EA=0;ET0=0;TR0=0;break;
case 0:P0=0x3f;P2=0x3f;i=0;Second_Counts=0;
}
}
}