当前位置:首页 > DIY高精度时钟、温度显示器Ds3231+12864+ds18b20+89c51 - 图文
}
DateDisplay(year,month,date);
//显示日期
delay1ms(1); lcd_pos(0,0); i=0;
while(a[i]!='\\0') { delay1ms(1); write_dat(a[i]); delay1ms(1); i++;
}
ReadTemperature();
delay1ms(1); lcd_pos(2,1); delay1ms(1); i=0; while(t[i]!='\\0') { delay1ms(1); write_dat(t[i]); delay1ms(2); i++; } } }
void shuaxin(void) { uint i; TimeDisplay(hour,min,sec); lcd_pos(1,1); //时间
i=0;
while(b[i]!='\\0') { delay1ms(1); write_dat(b[i]); delay1ms(1); i++; }
DateDisplay(year,month,date); //显示日期
//显示温度
delay1ms(1); lcd_pos(0,0); i=0; while(a[i]!='\\0') { delay1ms(1); write_dat(a[i]); delay1ms(1); i++; } }
void sotp(void) { uint i; while(1) { duan1: if(K1==0) { delay1ms(100); if(K1==0) { Readtime(); shuaxin(); i=0; goto duan2; } } else {goto duan5;} duan2: if(K2==0) { delay1ms(100); if(K2==0) { i++; if(i>6){i=0;} shuaxin(); }
} switch(i) { case 0: if(K3==0){delay1ms(100);if(K3==0){year=year+1;} if(year>=100){year=0;} shuaxin();} break; case 1: if(K3==0){delay1ms(100);if(K3==0){month=month+1;} if(month>=13){month=0;} shuaxin();} break; case 2: if(K3==0){delay1ms(100);if(K3==0){date=date+1;} if(date>=32){date=0;} shuaxin();} break; case 3: if(K3==0){delay1ms(100);if(K3==0){hour=hour+1;} if(hour>=25){hour=0;} shuaxin();} break; case 4: if(K3==0){delay1ms(100);if(K3==0){min=min+1;} if(min>=61){min=0;} shuaxin();} break; case 5: if(K3==0){delay1ms(100);if(K3==0){sec=sec+1;} if(sec>=61){sec=0;} shuaxin();} break; } duan4: if(K4==0) { delay1ms(100); if(K4==0) { ModifyTime(year,month,date,hour,min,sec); goto duan5; ///////////////////*******************////////// } } else {goto duan2;}
duan5: Readtime(); xianshi(); } }
main() { lcd_init(); delay1ms(5); InitDS3231(); delay1ms(5); delay1ms(5); sotp(); }
/*主程序*/
共分享92篇相关文档