sbit beep=P3^0; sbit test=P3^6; uchar shi[]={0,1,2,3,4,5,6,7,8,9,10};//闹钟 uchar fen[]={0,0,0,0,0,0,0,0,0,0,0}; uchar mode=0;//模式 uchar flag=0;//切换 uchar sec=0; uchar disp1[]="2021.03.10 3"; uchar disp2[]="00:00:00 "; uchar disp3[]="00:00"; uchar disp4[]="clock00"; uchar start=0; //延时 void delay(uint i) { while(i--) { if(!k6)//停止闹钟 { start=0; break; while(!k6); } } } void delays(uchar i)//秒延时 { uchar j; while(i--) { for(j=0;j<50;j++) delay(1000); } } //闹钟 void buzzr1() //低频 { uint i; if(start>0) { for(i=0;i<1000;i++) { beep=0; delay(50); if(!k6)//停止闹钟 { start=0; beep= 1; break; while(!k6); } } } } void buzzr2() //高频 { uint i; if(start>0) { for(i=0;i<2000;i++) { beep=0; delay(25); if(!k6)//停止闹钟 { start=0; beep= 1; break; while(!k6); } } } } void nao()//闹钟控制 { switch(start) { case 1: buzzr1();delays(1); break; case 2: buzzr1();delays(1); buzzr2();delays(1); break; case 3: buzzr1();delays(1); buzzr2();delays(1); buzzr2();delays(1); break; case 4: buzzr1();delays(1); buzzr1();delays(1); buzzr2();delays(1); break; case 5: buzzr1(); buzzr1();delays(1); buzzr2(); buzzr2();delays(1); break; case 6: buzzr1(); buzzr1();delays(1); buzzr2();delays(1); break; case 7: buzzr1();delays(1); buzzr2(); buzzr2();delays(1); break; case 8: buzzr1(); buzzr1(); buzzr1();delays(3); break; case 9: buzzr2(); buzzr2();delays(2); break; case 10: buzzr1(); break; case 11: buzzr1();delays(1); buzzr1();delays(1); buzzr1();delays(4); buzzr2();delays(1); buzzr2();delays(1); buzzr2();delays(4); } } |