#include #include unsigned char data dis_digit; unsigned char key_s, key_v; unsigned char code dis_code[11]={0xc0,0xf9,0xa4,0xb0, // 0, 1, 2, 3 0x99,0x92,0x82,0xf8,0x80,0x90, 0xff};// 4, 5, 6, 7, 8, 9, off unsigned char data dis_buf[8]; unsigned char data dis_index; unsigned char hour,min,sec; unsigned char sec100; sbit K1 = P1^4; sbit K2 = P1^5; bit scan_key(); void proc_key(); void inc_sec(); void inc_min(); void inc_hour(); void display(); void delayms(unsigned char ms); void main(void) { P0 = 0xff; P2 = 0xff; TMOD = 0x11; // 定时器0, 1 工作模式1, 16 位定时方式 TH1 = 0xdc; TL1 = 0; TH0 = 0xFC; TL0 = 0x17; hour = 12; min = 00; sec = 00; sec100 = 0; dis_buf[0] = dis_code[hour / 10]; // 时十位 dis_buf[1] = dis_code[hour % 10]; // 时个位 dis_buf[3] = dis_code[min / 10]; // 分十位 dis_buf[4] = dis_code[min % 10]