《单片机程序 万年历》由会员分享,可在线阅读,更多相关《单片机程序 万年历(6页珍藏版)》请在金锄头文库上搜索。
1、 万年历万年历系统功能:万年历,可以显示年月日时间。选用芯片:80C51 单片机。电路框图:程序代码(C 语言):#include #include #include #define lcdwritecmd XBYTE0xFC00 #define ledwritedat XBYTE0xFE00 sbit SCL=P10 ; sbit SDA=P11 ; char tab2; unsigned char year,mon,day,hour,min,sec,state,hudsec; /=延时函数=void delay(unsigned char n) unsigned char i,j;for(
2、i=0;i4) /= /=显示年月日时分秒的函数=void display() char ch;PCF8583_read();tab0=2;tab1=0;displaystring(0x83,2,year=(day6)+0x0E;datachang(year);displaystring(0x85,2,ch=-;writecmd(0x87);writedata(ch);mon=mondatachang(mon);displaystring(0x88,2,day=daydatachang(day);displaystring(0x8b,2, ch=-;writecmd(0x8a);writeda
3、ta(ch);datachang(hour);displaystring(0x80+0x44,2, ch=:;writecmd(0x80+0x46);writedata(ch);datachang(sec);displaystring(0x80+0x4A,2,ch=:;writecmd(0x80+0x49);writedata(ch);datachang(min);displaystring(0x80+0x47,2, /= /=初始化函数=void init() writecmd(0x38);writecmd(0x0c);writecmd(0x06);writecmd(0x80);PCF8583_write(0x00,0x00);delay(200); /= /=主函数=void main() init(); while(1)display(); /=