资源预览内容
第1页 / 共14页
第2页 / 共14页
第3页 / 共14页
第4页 / 共14页
第5页 / 共14页
第6页 / 共14页
第7页 / 共14页
第8页 / 共14页
第9页 / 共14页
第10页 / 共14页
亲,该文档总共14页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述
可调时间万年历可调时间万年历 C C 程序程序#include#include#define uchar unsigned char#define uint unsigned intsbit P2_0=P20;sbit dula1=P24;sbit wela1=P25;sbit dula=P26;sbit wela=P27;sbit P2_1=P21; sbit P2_3=P23; /按键 1 4 9 16uchar code tabledu=0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71;uchar code tabledu1=0xbf,0x86,0xdb,0xcf,0xe6,0xed,0xfd,0x87,0xff,0xef,0xf7,0xfc,0xb9,0xde,0xf9,0xf1;uchar a,b,c,d,e,f,g,h;uchar sec,min,hour,day=04,mnt=01;uchar flag=0;uint num,num1=6,num2,year=2013;display(uchar,uchar,uchar,uchar,uchar,uchar,uchar,uchar,uchar,uchar,uchar,uchar,uchar,uchar,uchar,uchar);delay(uchar);void time();void time1();void tz();void main()TMOD=0x52;EA=1;ET0=1;ET1=1;EX0=1;TH0=0x06;TL0=0x06;TH1=0xf0; /主函数TL1=0xd7;IT0=1;TR0=1;TR1=1;while(1)if(num1=8)num1=1;tz();display(num1,17,hour/10,hour%10,min/10,min%10,sec/10,sec%10,year/1000,year/100%10,year/10%10,year%10,mnt/10,mnt%10,day/10,day%10);time();if(flag=1)time1();flag=0;void int0() interrupt 0 using 1TR0=0;TR1=0;num2+;void t0() interrupt 1 using 2TH0=0x06;TL0=0x06;P2_0=1;P2_0=0;void t1() interrupt 3 using 3TH1=0xf0;TL1=0xd7;sec+;void time()if(sec=60)sec=0; /时 分 秒min+;if(min=60)min=0;hour+;if(hour=24)hour=0;flag=1;void time1()uchar day1;if(day=28)if(mnt=2)if(year%4=0elseday1=29;elseswitch(mnt)case 1: day1=32; /年 月 日break;case 3: day1=32;break;case 4: day1=31;break;case 5: day1=32;break;case 6: day1=31;break;case 7: day1=32;break;case 8: day1=32;break;case 9: day1=31;break;case 10: day1=32;break;case 11: day1=31;break;case 12: day1=32;break;day+;num1+;if(day=day1)mnt+;day=0;if(mnt=12)year+;mnt=0;void tz()if(TR0=0 /调整时间if(P2_1=0)sec+;while(P2_1=0);if(num2=2if(P2_1=0)min+;while(P2_1=0);if(num2=3if(P2_1=0)hour+;while(P2_1=0);if(num2=4if(P2_1=0)num1+;while(P2_1=0);if(num2=5if(P2_1=0)day+;while(P2_1=0);if(num2=6if(P2_1=0)mnt+;while(P2_1=0);if(num2=7if(P2_1=0)year+;while(P2_1=0);if(num2=8)TR0=1;TR1=1;num2=0;display(uchar a,uchar b,uchar c,uchar d,uchar e,uchar f,uchar g,uchar h,uchar i,uchar j,uchar k,uchar l,uchar m,uchar n,uchar o,uchar p)uchar temp;temp=0x0f;P1=0xff;wela=1;/消除余晖wela=0;P1=tabledua;dula=1;dula=0;temp=temp+1;P1=0x00;wela=1; wela=0;delay(1);/*P1=0xff;wela=1;/消除余晖wela=0;P1=tabledub;dula=1;dula=0;temp=temp+1;P1=temp;wela=1;wela=0;delay(1);*/P1=0xff;wela=1;/消除余晖wela=0;P1=tableduc;dula=1;dula=0;temp=temp+2;P1=temp;wela=1;wela=0;delay(1); /数码管显示P1=0xff;wela=1;/消除余晖wela=0;P1=tabledu1d;dula=1;dula=0;temp=temp+1;P1=temp;wela=1;wela=0;delay(1);P1=0xff;wela=1;/消除余晖wela=0;P1=tabledue;dula=1;dula=0;temp=temp+1;P1=temp;wela=1;wela=0;delay(1);P1=0xff;wela=1;/消除余晖wela=0;P1=tabledu1f;dula=1;dula=0;temp=temp+1;P1=temp;wela=1;wela=0;delay(1);P1=0xff;wela=1;/消除余晖wela=0;P1=tabledug;dula=1;dula=0;temp=temp+1;P1=temp;wela=1;wela=0;delay(1);P1=0xff;wela=1;/消除余晖wela=0;P1=tableduh;dula=1;dula=0;temp=temp+1;P1=temp;wela=1;wela=0;delay(1);P1=0xff;wela=1;/消除余晖wela=0;P1=tabledui;dula1=1;dula1=0;temp=temp+1;P1=temp;wela=1;wela=0;delay(1);P1=0xff;wela=1;/消除余晖wela=0;P1=tableduj;dula1=1;dula1=0;temp=temp+1;P1=temp;wela=1;wela=0;delay(1);P1=0xff;wela=1;/消除余晖wela=0;P1=tableduk;dula1=1;dula1=0;temp=temp+1;P1=temp;wela=1;wela=0;delay(1);P1=0xff;wela=1;/消除余晖wela=0;P1=tabledu1l;dula1=1;dula1=0;temp=temp+1;P1=temp;wela=1;wela=0;delay(1);P1=0xff;wela=1;/消除余晖wela=0;P1=tabledum;dula1=1;dula1=0;temp=temp+1;P1=temp;wela=1;wela=0;delay(1);P1=0xff;wela=1;/消除余晖wela=0;P1=tabledu1n;dula1=1;dula1=0;temp=temp+1;P1=temp;wela=1;wela=0;delay(1);P1=0xff;wela=1;/消除余晖wela=0;P1=tableduo;dula1=1;dula1=0;temp=temp+1;P1=temp;wela=1;wela=0;delay(1);P1=0xff;wela=1;/消除余晖wela=0;P1=tabledup;dula1=1;dula1=0;temp=temp+1;P1=temp;wela=1;wela=0;delay(1);delay(uchar x)uchar a,b;for(a=x;a0;a-) /延时for(b=200;b0;b-);
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号