实现简单秒表,按键控制秒表的开始、暂停与重置。
#include "reg52.h"
typedef unsigned int u16;
typedef unsigned char u8;
#define led P0
sbit k3=P3^2;
sbit k4=P3^3;
sbit LSA=P2^2;
sbit LSB=P2^3;
sbit LSC=P2^4;
u8 LED[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x40};
u8 L[8][3]={
{1,1,1},{0,1,1},{1,0,1},{0,0,1},{1,1,0},{0,1,0},{1,0,0},{0,0,0}};
static u8 hour =0;
static u8 min=0;
static u8 s=0;
char Sh(char lo)
{
switch(lo)
{
case 0:return hour/10;
case 1:return hour%10;
case 2:return 10;
case 3:return min/10;
case 4:return min%10;
case 5:return 10;
case 6:return s/10;
case 7:return s%10;
}
}
void Initial()
{
TMOD=TMOD||0x01;
TH0=0xfc;
TL0=0x18;
ET0=1;
IT0=1;
EX0=1;
IT1=1;
EX1=1;
TR0=1;
EA=1;
}
void delay(u16 i)
{
while(i--);
}
void main()
{
Initial();
while(1)
{
u8 i=0;
for(i=0;i<8;i+&#