简易电子钟
#include <reg51.h>
#include <display.h>
void T0_ISR_Init(void);//初始化计数器1
void T1_ISR_Init(void);//初始化计数器2
void Timering();
unsigned char Key_Press_1(void);
unsigned char Key_Press_2(void);
void delayms(unsigned char n);
unsigned char Timer[6] = {0};
unsigned char flag,t_50ms;
char Index = 0;
sbit Key_1 = P2 ^ 2;
sbit Key_2 = P2 ^ 3;
void main()
{
T0_ISR_Init();
T1_ISR_Init();
while(1)
{
TempData[0] = Seg_Code[Timer[5]];
TempData[1] = Seg_Code[Timer[4]];
TempData[2] = Seg_Code[10];
TempData[3] = Seg_Code[Timer[3]];
TempData[4] = Seg_Code[Timer[2]];
TempData[5] = Seg_Code[10];
TempData[6] = Seg_Code[Timer[1]];
TempData[7] = Seg_Code[Timer[0]];
flag = Key_Press_2();
if(1 == flag)
{
Index ++;
if(Index >= 6)
Index = 0;
}
else if(2 == flag)
{
Index = 0;
}
if(1 == Key_Press_1())