语音芯片时钟电路(整点报时名闹铃设置)程序
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
#include
unsigned char code table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f}; unsigned char code tab[]={0xfd,0xfb,0xf7,0xef,0xdf,0xbf};
unsigned char code ts[]={0x00,0x08,0x10,0x18,0x20,0x28,0x30,0x38,0x40,0x48,0x50}; unsigned char wei[]={0,1,2,3,4,5};
unsigned char sec,min,hou,rsec,rmin,rhou,tcont;
unsigned char a0,a1,a2;
unsigned char smh;
void delay(void) //延时子程序
{ unsigned char i,j;
for (i=10;i>0;i--)
for(j=248;j>0;j--);
}
void delay2(void) //1420专用延时子程序
{ unsigned char i,j,k;
for (i=200;i>0;i--)
for(j=248;j>0;j--)
for(k=20;k>0;k--);
}
void play(unsigned char temp) //1420播放子程序
{ P1=0;P3_0=1;P3_1=1;P1=temp;
P3_1=0;
delay2();
P1=0;
P3_1=1;
}
void display(void) //显示子程序
{ for(a2=0;a2<6;a2++)
{ wei[0]=hou/10;
wei[1]=hou%10;
wei[2]=min/10;
wei[3]=min%10;
wei[4]=sec/10;
wei[5]=sec%10;
P2=tab[a2];
P0=table[wei[a2]];
delay();
}
}
void rdisplay(void) //闹钟显示子程序
{ for(a2=0;a2<6;a2++)
{ wei[0]=rhou/10;
wei[1]=rhou%10;
wei[2]=rmin/10;
wei[3]=rmin%10;
wei[4]=rsec/10;
wei[5]=rsec%10;
P2=tab[a2];
P0=table[wei[a2]];
delay();
}
}
void ring(void) //闹钟控制子程序{ while(P3_5==0)
rdisplay();
smh=0;
a0=0;
while(a0==0)
{ rdisplay();
if(P3_3==0)
{ delay();
if(P3_3==0)
{ switch(smh)
{ case 0:
rsec++;
break;
case 1:
rmin++;
break;
case 2:
rhou++;
break;
}
if(rsec==60)
{ rsec=0;
rmin++;
}
if(rmin==60)
{ rmin=0;
rhou++;
}
if(rhou==24)
rhou=0;
}
while(P3_3==0)
rdisplay();
}
if(P3_2==0)
{ delay();
if(P3_2==0)
{ switch(smh)
{ case 0:
rsec--;
break;
case 1:
rmin--;
break;
case 2:
rhou--;
break;
}
if(rsec==-1)
{ rsec=59;
rmin--;
}
if(rmin==-1)
{ rmin=59;
rhou--;
}
if(rhou==-1)
rhou=23;
}
while(P3_2==0)
rdisplay();
}
if(P3_4==0)
{ delay();
if(P3_4==0)
smh++;
if(smh==3)
smh=0;
while(P3_4==0)
rdisplay();
}
if(P3_5==0)
{ delay();
if(P3_5==0)
a0=1;
while(P3_5==0)
rdisplay();
break;
}
}
smh=0;
}
void examring(void) //闹钟播放子程序
{ unsigned char i,j,k;
if(sec==rsec)
{ if(min==rmin)
{ if(hou==rhou)
{ P1=0;P3_0=1;P3_1=1;P1=0x70;
P3_1=0;
for (i=150;i>0;i--)
display();
P1=0;
P3_1=1;
P1=0;P3_0=1;P3_1=1;P1=0x70;
P3_1=0;
for (i=150;i>0;i--)
display();
P1=0;
P3_1=1;
P1=0;P3_0=1;P3_1=1;P1=0x70;
P3_1=0;
for (i=150;i>0;i--)
display();
P1=0;
P3_1=1;
P1=0;P3_0=1;P3_1=1;P1=0x70;
P3_1=0;
for (i=150;i>0;i--)
display();
P1=0;
P3_1=1;
}
}
}
}
void zhengdian(void) //整点报时子程序
{ unsigned char dian;
if(sec==0)
{ if(min==0)
{ dian=hou/10;
if(dian==0)
{play(0x60);play(0x68);dian=hou%10;dian=ts[dian];play(dian);play(0x58);}