51单片机+ds1302+DS18b20温度时钟(电路图+C语言程序)

} } } }

dis(countdown_hour/10,countdown_hour,countdown_minute/10,countdown_minute,countdown_second/10,countdown_second);// break; case 22:

if(countdown_flag>0 && countdown_flag<7) {

speak=0;

if(second_flag==1) {

second_flag=0; countdown_flag++; } } else {

speak=1; }

dis(countdown_hour/10,countdown_hour,countdown_minute/10,countdown_minute,countdown_second/10,countdown_second);// break; case 23:

dis(msecond_minute/10,msecond_minute,msecond_second/10,msecond_second,msecond_msecond,12); break; case 24:

if(msecond_flag==1) {

msecond_flag=0;

msecond_msecond++; if(msecond_msecond==10) {

msecond_msecond=0; msecond_second++; if(msecond_second==60) {

msecond_second=0;

msecond_minute++;

if(msecond_minute==100) {

msecond_minute=99; flag1=23; } } } }

dis(msecond_minute/10,msecond_minute,msecond_second/10,msecond_second,msecond_msecond,12); break; case 25:

dis(zancun3/10,zancun3,zancun2/10,zancun2,zancun1/10,zancun1); break; default: break; } } }

//************************************************** //S1按键处理函数 void judge_s1() {

s1_bit=1;//置IO为1,准备读入收据 if(s1_bit==0)//判断是否有按键按下 {

delay_50us(1);// 延时,去除机械抖动 if(s1_bit==0) {

switch(flag1) {

case 0: case 1: case 2: case 3: case 4: case 6: case 7: case 8: case 10: case 11:

case 12: case 13: case 15: case 16: case 17: case 18: case 19:

flag1++; break; case 9:

flag1=6; break; case 14:

flag1=10; break; case 20:

flag1=15; break; case 5: case 21: case 22:

case 23://系统从秒表状态复位 case 24://系统从秒表状态复位 case 25://系统从计数器复位 flag1=0; break; default: break; } while(s1_bit==0) {

judge_dis(); }//等待按键释放 } } }

//************************************************** //S2按键处理函数 void judge_s2() {

s2_bit=1;//置IO为1,准备读入收据 if(s2_bit==0)//判断是否有按键按下 {

delay_50us(1);// 延时,去除机械抖动

if(s2_bit==0) {

switch (flag1) {

case 1: //在显示SET1状态下按S2件,进入修改时间 flag1=6;

zancun4=hour_count&0xf0; zancun4>>=4;

zancun6=hour_count&0x0f; zancun1=zancun4*10+zancun6; //zancun1=hour_count;

zancun5=minute_count&0xf0; zancun5>>=4;

zancun6=minute_count&0x0f; zancun2=zancun5*10+zancun6; // zancun2=minute_count; break;

case 2://在显示SET2状态下按S2,进入设置闹钟 zancun1=clock_hour; zancun2=clock_minute; flag1=10; break;

case 6://修改时钟小时十位状态下按S2件 case 7://修改时钟小时个位状态下按S2件 case 8://修改时钟分钟十位状态下按S2件 case 9://修改时钟分钟个位状态下按S2件 //zancun4=zancun1/10;

tab23[2]=zancun1/10*16+zancun1;

//zancun5=zancun2&0xf0; //zancun5>>=4;

tab23[1]=zancun2/10*16+zancun2; hour_count=tab23[2]; minute_count=tab23[1]; second_count=0; tab23[0]=0;

set_ds1302();//设置DS1302的初始时间 flag1=0; break;

case 10://修改闹钟小时十位状态下按S2 case 11://修改闹钟小时个位状态下按S2 case 12://修改闹钟分钟十位状态下按S2 case 13://修改闹钟分钟个位状态下按S2

联系客服:779662525#qq.com(#替换为@)