case 4: { break; }
case 5://切换到调节闹钟显示 { aa=0; bb=0; break; }
case 6: { bb++;//调节闹钟分钟 if(bb>=60) bb=0; break; }
case 7: { aa++;//调节时钟分钟 if(aa>=24) aa=0; break; }
}
}
}
PC=0xfb;//扫描倒数第三列 temp=PC;
temp=temp&0xf0; if(temp!=0xf0) { delay(10); temp=PC; temp=temp&0xf0; if(temp!=0xf0) { switch(temp) { case 0x70:num=8; break;
32
case 0xb0:num=9; break; case 0xd0:num=10; break; case 0xe0:num=11; break; } while(temp!=0xf0) { temp=PC; temp=temp&0xf0; dispaly(hour1,hour2,minute1,minute2,second1,second2); } switch(num) { case 8: case 9: case 10: case 11: { flag=~flag; D0=~D0; num=0; break;//闹钟开关 } } } } }
void main() { EA=1; TMOD=0X01; ET0=1; TH0=(65536-500)/256; TL0=(65536-500)%6; PCON=0x80;
33
if((read_set1302(0x81)>>7)==0x01)//如果DS1302掉电则重新设置时间 { init1302(); } while(1) { aa1=aa/10; aa2=aa; bb1=bb/10; bb2=bb; cc1=cc/10; cc2=cc; readtime(); hour1=hour/10; hour2=hour; minute1=minute/10; minute2=minute; second1=second/10; second2=second; if(num>=0&&num<=3) dispaly(hour1,hour2,minute1,minute2,second1,second2); else dispaly(aa1,aa2,bb1,bb2,cc1,cc2); keyboard(); if((second==0&&minute==0)||(aa==hour&&bb==minute&&flag==1)) TR0=1; } }
void time0() interrupt 1 { TH0=(65536-400)/256; TL0=(65536-400)%6; a0++; buzzer=~buzzer; if(a0>10000) { a0=0; TR0=0;
34
}
}
buzzer=1;
35