可以显示温度的万年历程序(已在PD1000开发板上运行)
具有温度指示的数字万年历设计方案
具有温度指示的数字万年历设计方案1 绪论随着电子技术的迅速发展,特别是随大规模集成电路出现,给人类生活带来了根本性的改变。
由其是单片机技术的应用产品已经走进了千家万户。
其中电子万年历就是一个典型的例子。
而且在万年历的基础上还可以扩展其它的实用功能,比如温度计。
万年历是采用数字电路实现对.时,分,秒.数字显示的计时装置,广泛用于个人家庭,车站,码头办公室等公共场所,成为人们日常生活中不可少的必需品,由于数字集成电路的发展和石英晶体振荡器的广泛应用,使得数字钟的精度,远远超过老式钟表,钟表的数字化给人们生产生活带来了极大的方便,而且大大地扩展了钟表原先的报时功能。
诸如定时自动报警、按时自动打铃、时间程序自动控制、定时广播、自动起闭路灯、定时开关烘箱、通断动力设备、甚至各种定时电气的自动启用等,但是所有这些,都是以钟表数字化为基础的。
因此,研究万年历及扩大其应用,有着非常现实的意义。
市场上有许多电子钟的专用芯片如:LM8363 、LM8365 等,但它们功能单一,电路连接复杂,不便于调试制作。
但是考虑到用单片机配合时钟芯片,可制成功能任意的电子钟,而且可以做到硬件简单、成本低廉。
所以本系统采用了以广泛使用的单片机AT89S52 技术为核心,配合时钟芯片DS1302 。
软硬件结合,使硬件部分大为简化,提高了系统稳定性,并采用LCD 显示电路、键盘电路,使人机交互简便易行,此外结合音乐闹铃电路、看门狗和供电电路。
本方案设计出的数字钟可以显示时间、设置闹铃功能之外。
本文首先描述系统硬件工作原理,并附以系统结构框图加以说明,着重介绍了本系统所应用的各硬件接口技术和各个接口模块的功能及工作过程, 其次,详细阐述了程序的各个模块和实现过程。
本设计以数字集成电路技术为基础,单片机技术为核心。
本文编写的主导思想是软硬件相结合,以硬件为基础,来进行各功能模块的编写。
本设计中我重点研究实现了单片机+ 时钟芯片这种模式的万年历,从原理上对单片机和时钟芯片有了深一步的认识,这些基本功能完成后,在软件基础上实现时间显示。
带温度显示的万年历_数码管显示(附电路图和源代码)
设计报告设计任务:设计一个智能化万年历时钟电路,LED数码管作为电路的显示部分,按钮开关作为调时部分,通过与单片机连接数码管动态显示年、月、日、时、分、秒、星期、温度。
并能准确计算闰年闰月的显示。
设计要求:通过与单片机连接数码管动态显示年、月、日、时、分、秒、星期等功能,并能准确计算闰年闰月的显示,三个个按钮连接P3.0、P3.1、P3.2可以精确调整每一个时间数值,通过对所设计的万年历时钟电路进行实验测试,达到了动态显示时间,随时调整时间等技术所连线路和单片机接口仿真图如图3所示:图3 仿真按键4)温度采集部分:DS18B20温度传感器,测温范围-55℃~+125℃,固有测温分辨率0.5℃。
独特的单线接口方式,DS18B20在与微处理器连接时仅需要一条口线即可实现微处理器与DS18B20的双向通讯。
DS18B20的采集数据通过DQ传入单片机,单片机读取数据后将数据输出!如图所示:程序如下:ReadOneChar(void){unsigned char i=0;// 定义i用于循环unsigned char dat = 0;// 读取的8位数据for (i=8;i>0;i--)//8次循环{DQ = 0;// 拉低DQ总线开始读时序dat>>=1;// dat左移一位DQ = 1; //释放DQ总线if(DQ)// 如果DQ=1,执dat|=0x80;(0x80即第7位为1,如果DQ为1,即读取的数据为1,将dat的第7为置1,然后dat>>=1,循环8次结束,dat 即为读取的数据)//DQ=0,就跳过dat|=0x80;Tdelay(4);// 延时以完成此次读时序,之后再读下一数据}return(dat); 返回读取的dat}//写一个字节WriteOneChar(unsigned char dat){unsigned char i=0;//for (i=8; i>0; i--)//{DQ = 0;//DQ = dat&0x01;//Tdelay(5);//延时以完成此次读时序,之后再读下一数据DQ = 1;//dat>>=1;//}}//读取温度ReadTemperature(void){unsigned char a=0;unsigned char b=0;unsigned int t=0;float tt=0;//Init_DS18B20();WriteOneChar(0xCC);// 写指令,跳过ROM,WriteOneChar(0x44);// 启动温度转换Init_DS18B20();WriteOneChar(0xCC);// 写指令,跳过ROM,WriteOneChar(0xBE);// 写指令,读暂存存储器a=ReadOneChar();//读低8位b=ReadOneChar();//读高8位t=b;//t<<=8;//t=t|a;//tt=t*0.0625;//t= tt*10+0.5;//return(t); //获得0.01°C 的精度并返回}LED数码管的选择LED数码管分为共阴和共阳两种,以利用STC89C51的P0口作为LED显示的数据部分,以P2口的七个口作为显示部分的位选,通过三八译码器和4-16译码器扩展为17位的位选分别接在一个四位数码管和13个数码管的位选部分。
单片机万年历温度检测C程序(1302+1820+1602+51)
1302+1820+1602+51万年历#include<reg51.H>#include<INTRINS.H>#define uchar unsigned char#define uint unsigned int#define TIME (0X10000-50000)#define FLAG 0XEF //闹钟标志//引脚连接图sbit rst=P3^5;sbit clk=P3^4;sbit io=P3^3;sbit rs=P1^5;sbit rw=P1^6;sbit e=P1^7;sbit DQ=P1^4; //温度输入口sbit beep=P3^2;sbit ACC_7=ACC^7;//全局变量及常量定义uchar i=20,j,time1[16];uchar alarm[2],time2[15],time[3];uchar code Day[]={31,28,31,30,31,30,31,31,30,31,30,31};//12个月的最大日期(非闰年)//音律表uint code table1[]={64260,64400,64524,64580,64684,64777,64820,64898,64968,65030,65058,65110,65157,65178,65217};//发声部分的延时时间uchar code table2[]={0x82,1,0x81,0xf4,0xd4,0xb4,0xa4,0x94,0xe2,1,0xe1,0xd4,0xb4,0xc4,0xb4,4,0};//LCD自建字uchar code tab[]={0x18,0x1b,5,4,4,5,3,0,0x08,0x0f,0x12,0x0f,0x0a,0x1f,0x02,0x02,//年0x0f,0x09,0x0f,0x09,0x0f,0x09,0x11,0x00,//月0x0f,0x09,0x09,0x0f,0x09,0x09,0x0f,0x00};//日//*******温度小数部分用查表法**********//uchar codeditab[16]={0x00,0x01,0x01,0x02,0x03,0x03,0x04,0x04,0x05,0x06,0x06,0x0 7,0x08,0x08,0x09,0x09};//闹钟中用的全局变量uchar th1,tl1;uchar temp_ioa[2]={0x00,0x00}; // 读出温度暂放bit flag; //18b20存在标志位/***********11微秒延时函数**********/delay(uint t){for(;t>0;t--);}/***********18B20复位函数**********/ow_reset(void){uchar i;DQ=1;_nop_();_nop_();DQ=0; //delay(50); // 550usDQ=1; //delay(6); // 66usfor(i=0;i<0x30;i++){if(!DQ)goto d1;}flag=0; //清标志位,表示ds1820不存在DQ=1;return;d1: delay(45); //延时500usflag=1;DQ=1; //置标志位,表示ds1820存在}/**********18B20写命令函数*********///向 1-WIRE 总线上写一个字节void write_byte(uchar val){uchar i;for (i=8; i>0; i--) //{DQ=1;_nop_();_nop_();DQ=0;_nop_();_nop_();_nop_();_nop_();_nop_();//5us DQ=val&0x01; //最低位移出delay(6); //66usval=val/2; //右移一位}DQ=1;delay(1);}/*********18B20读1个字节函数********///从总线上读取一个字节uchar read_byte(void){uchar i;uchar value=0;for (i=8;i>0;i--){DQ=1;_nop_();_nop_();value>>=1;DQ=0; //_nop_();_nop_();_nop_();_nop_(); //4usDQ=1;_nop_();_nop_();_nop_();_nop_(); //4usif(DQ)value|=0x80;delay(6); //66us}DQ=1;return(value);}/***********读出温度函数**********/read_temp(){ow_reset(); //总线复位if(!flag) //判断ds1820是否存在?若ds18b20不存在则返回 return;//write_byte(0xCC); // Skip ROM//write_byte(0x44); // 发转换命令//delay(70);write_byte(0xCC); //发Skip ROM命令write_byte(0xBE); //发读命令temp_ioa[0]=read_byte(); //温度低8位temp_ioa[1]=read_byte(); //温度高8位ow_reset();write_byte(0xCC); // Skip ROMwrite_byte(0x44); // 发转换命令}/***********温度数据处理函数**********/work_temp(){uchar n=0,m;if(temp_ioa[1]>127)//负温度求补码{temp_ioa[1]=(256-temp_ioa[1]);temp_ioa[0]=(256-temp_ioa[0]);n=1;}time2[13]=ditab[temp_ioa[0]&0x0f]+'0';time2[12]='.';m=((temp_ioa[0]&0xf0)>>4)|((temp_ioa[1]&0x0f)<<4);// if(n){m-=16;}time2[9]=m/100+'0';time2[11]=m%100;time2[10]=time2[11]/10+'0';time2[11]=time2[11]%10+'0';if(time2[9]=='0')//最高位为0时都不显示{time2[9]=0x20;if(n)//负温度时最高位显示"-"{time2[9]='-';}if(time2[10]=='0'){if(n){time2[10]='-';time2[9]=0x20;}elsetime2[10]=0x20;if(time2[11]=='0'&&time2[13]=='0')time2[11]=time2[12]=0x20;}}}delay1ms(uchar time) //延时1ms{uchar i,j;for(i=0;i<time;i++){for(j=0;j<250;j++);}}//LCD驱动部分enable(){rs=0;rw=0;e=0;delay1ms(3);e=1;}write2(uchar i){P0=i;rs=1;rw=0;e=0;delay1ms(2);e=1;}write1(uchar data *address,m) {uchar i,j;for(i=0;i<m;i++,address++) {j=*address;write2(j);}}//LCD显示lcdshow(){P0=0XC; //显示器开、光标关enable();P0=0x80; //写入显示起始地址enable();write1(time1,16);P0=0xc1; //写入显示起始地址enable();write1(time2,15);}//自建字zijianzi(){uchar i;P0=0x40;enable();for(i=0;i<32;i++){write2(tab[i]);delay1ms(2);}}//DS1302读写子程序write(uchar address){uchar i;clk=0;_nop_();rst=1;_nop_();for(i=0;i<8;i++){io=address&1;_nop_();clk=1;address>>=1;clk=0;}}uchar read(){uchar i,j=0;for(i=0;i<8;i++){j>>=1;_nop_();clk=0;_nop_();if(io)j|=0x80;_nop_();clk=1;}return(j);}//部分显示数据初始化timestart(){time1[1]=time1[13]=time2[8]=time2[9]=time2[10]=0x20,time2[14]=0; time1[6]=1,time1[9]=2,time1[12]=3,time1[2]='2',time1[3]='0'; time1[14]='W',time2[2]=time2[5]=':';write(0xc1);alarm[0]=read();rst=0;write(0xc3);alarm[1]=read();rst=0;write(0xc5);time1[0]=read();rst=0;}//读取时间readtime(){uchar i,m,n;write(0x8d); //读取年份m=read();rst=0;time1[4]=m/16+0x30;time1[5]=m%16+0x30;write(0x8b); //读取星期m=read();rst=0;time1[15]=m+0x30;for(i=7,n=0x89;i<11;i+=3,n-=2) //读取月份和日期{write(n);m=read();rst=0;time1[i]=m/16+0x30;time1[i+1]=m%16+0x30;}for(m=0,i=0,n=0x85;i<7;i+=3,n-=2,m++) //读取时,分,秒{write(n);time[m]=read();rst=0;time2[i]=time[m]/16+0x30;time2[i+1]=time[m]%16+0x30;}}time0() interrupt 1 using 1{i--;if(i==0){if(j!=0)j--;i=20;}TH0=TIME/256,TL0=TIME%256;}//闹钟部分intime1() interrupt 3{TH1=th1,TL1=tl1;beep=!beep;}showalarm(){uchar i,j,a,b,n;ET1=1;for(j=0;j<6;j++){i=0;while(1){a=table2[i];if(a==0)break;b=a&0xf;a>>=4;if(a==0){TR1=0;goto D1;}a=((--a)<<1)/2;TH1=th1=table1[a]/256,TL1=tl1=table1[a]%256; TR1=1;D1: do{b--;for(n=0;n<3;n++){readtime();lcdshow();P2=0xf7;if(P2==0xe7){delay1ms(100);if(P2==0xe7){TR1=0;ET1=0;return;}}}}while(b!=0);i++;}TR1=0;}ET1=0;}//根据日期的变动自动调整星期uchar setweek(){uchar i=5,j,n;j=(time1[4]&0xf)*10+(time1[5]&0xf); n=j/4;i=i+5*n;n=j%4;if(n==1)i+=2;else if(n==2)i+=3;else if(n==3)i+=4;j=(time1[7]&0xf)*10+(time1[8]&0xf); if(j==2)i+=3;else if(j==3)i+=3;else if(j==4)i+=6;else if(j==5)i+=1;else if(j==6)i+=4;else if(j==7)i+=6;else if(j==8)i+=2;else if(j==9)i+=5;else if(j==11)i+=3;else if(j==12)i+=5;if(n==0)if(j>2)i++;j=(time1[10]&0xf)*10+(time1[11]&0xf);i+=j;i%=7;if(i==0)i=7;return(i);}//设置时间settime(){uchar i=0x85,year,month,day,n;time2[6]=time2[7]=0x30,time1[14]=time1[15]=0x20; lcdshow();while(1){P0=0xe; //显示器开、光标开enable();P0=i; //定光标enable();P2=0xf7;if(P2!=0XF7){delay1ms(100); //延时0.1s去抖动if(P2!=0XF7){j=7;if(P2==0X77){i+=3;if(i==0x8e)i=0xc2;else if(i>0xc5)i=0x85;}else if(P2==0xb7){year=(time1[4]&0xf)*10+(time1[5]&0xf); month=(time1[7]&0xf)*10+(time1[8]&0xf); day=(time1[10]&0xf)*10+(time1[11]&0xf); if(i==0x85){year++;if(year>99)year=0;if((year%4)!=0)if(month==2&&day==29)day=28;}else if(i==0x88){month++;if(month>12)month=1;if(day>Day[month-1]){day=Day[month-1];if(month==2&&(year%4)==0)day=29;}}else if(i==0x8b){day++;if(day>Day[month-1]){if(month==2&&(year%4)==0){if(day>29)day=1;}if(month!=2)day=1;}}else if(i==0xc2){n=(time2[0]&0xf)*10+(time2[1]&0xf);n++;if(n>23)n=0;time2[0]=n/10+0x30;time2[1]=n%10+0x30;}else{n=(time2[3]&0xf)*10+(time2[4]&0xf);n++;if(n>59)n=0;time2[3]=n/10+0x30;time2[4]=n%10+0x30;}time1[4]=year/10+0x30;time1[5]=year%10+0x30;time1[7]=month/10+0x30;time1[8]=month%10+0x30;time1[10]=day/10+0x30;time1[11]=day%10+0x30;lcdshow();}else if(P2==0xd7){write(0x8c);write((time1[4]&0xf)*16+(time1[5]&0xf));rst=0;write(0x8a);write(setweek());rst=0;for(i=7,n=0x88;i<11;i+=3,n-=2){write(n);write((time1[i]&0xf)*16+(time1[i+1]&0xf)); rst=0;}for(i=0;i<7;i+=3,n-=2){write(n);write((time2[i]&0xf)*16+(time2[i+1]&0xf)); rst=0;}TR0=0;time1[14]='W';return;}else{TR0=0;time1[14]='W';return;}}}if(j==0){TR0=0;time1[14]='W';return;}}}//设置闹钟setalarm(){uchar i,n;for(i=1;i<16;i++){time1[i]=0x20;}time2[0]=alarm[0]/16+0x30;time2[1]=(alarm[0]&0xf)+0x30;time2[3]=alarm[1]/16+0x30;time2[4]=(alarm[1]&0xf)+0x30;time2[6]=time2[7]=0x30;lcdshow();i=0xc2;while(1){P0=0xe; //显示器开、光标开enable();P0=i; //定光标enable();P2=0xf7;if(P2!=0XF7){delay1ms(100); //延时0.1s去抖动 if(P2!=0XF7){j=7;if(P2==0X77){i+=3;if(i>0xc5)i=0xc2;}else if(P2==0xb7){if(i==0xc2){n=(time2[0]&0xf)*10+(time2[1]&0xf);n++;if(n>23)n=0;time2[0]=n/10+0x30;time2[1]=n%10+0x30;}else{n=(time2[3]&0xf)*10+(time2[4]&0xf);n++;if(n>59)n=0;time2[3]=n/10+0x30;time2[4]=n%10+0x30;}lcdshow();}else if(P2==0xd7){write(0xc0);write((time2[0]&0xf)*16+(time2[1]&0xf)); rst=0;write(0xc2);write((time2[3]&0xf)*16+(time2[4]&0xf)); rst=0;time1[0]=FLAG;write(0xc4);write(time1[0]);rst=0;TR0=0;timestart();return;}else{TR0=0;timestart();return;}}}if(j==0){TR0=0;timestart();return;}}}main(){IE=0X82;TMOD=0x11;write(0x8E); //禁止写保护write(0);rst=0;P0=1; //清屏并光标复位enable();P0=0X38; //设置显示模式:8位2行5x7点阵enable();P0=6; //文字不动,光标自动右移enable();zijianzi(); //自建字timestart();while(1){readtime(); //读取时间read_temp(); //读出18B20温度数据 work_temp(); //处理温度数据lcdshow(); //显示时间if(time1[0]!=0x20)if(time[0]==alarm[0])if(time[1]==alarm[1])if(time[2]==0)showalarm();P2=0xf7;if((P2&0XF0)!=0XF0){delay1ms(100); //延时0.1s去抖动 if((P2&0XF0)!=0XF0){j=7;TH0=TIME/256,TL0=TIME%256;TR0=1;if(P2==0x77){settime();}else if(P2==0XB7){setalarm();}else if(P2==0XD7){TR0=0;if(time1[0]==FLAG)time1[0]=0x20;elsetime1[0]=FLAG;write(0xc4);write(time1[0]);rst=0;}}}delay1ms(100);}}单片机万年历——基于1302和1602(1篇)2009-12-06 21:191302和1602的接法在我相册里面使用1602液晶显示DS1302+c51时钟[注12M晶振]=============================================================*/#include <AT89x52.h>#include <string.h>#include < intrins.h >#define delayNOP() ; {_nop_() ;_nop_() ;_nop_() ;_nop_() ;} ;#define LCM_RW P3_1 //定义引脚#define LCM_RS P3_0#define LCM_E P3_2#define LCM_Data P0#define Busy 0x80 //用于检测LCM状态字中的Busy标识#define uchar unsigned charsbit T_CLK=P2^4;sbit T_IO =P2^5;sbit T_RST=P2^6;sbit ACC0=ACC^0;sbit ACC7=ACC^7;sbit system=P1^1; //模式sbit TimerUp=P1^2; //时间加sbit TimerDown=P1^0; //时间减sbit Speaker=P2^1; //蜂鸣器void Set(uchar,uchar); //根据选择调整相应项目void RTInputByte(uchar); //输入 1Byte */uchar RTOutputByte(void); //输出 1Byte */void W1302(uchar, uchar); //向DS1302写入一个字节uchar R1302(uchar); //从DS1302读出一个字节void Set1302(uchar * ); //设置时间void KeySound(); //按键音void ClockSound(); //闹铃蜂鸣声uchar id,msec,model,LedTime,d;bit a,b; //闪烁标志位uchar inittime[7]={0x00,0x10,0x19,0x29,0x03,0x04,0x06}; //初始化后设置为:06年3月29日星期3 19点10分0秒void Out_LCM(void); //显示屏幕void model0(void); //显示输出void model1(void);void model2(void);void model3(void);void model4(void);void model5(void);void model6(void);void id_case1_key(); //项目调整void Modset(); //模式键处理void WriteDataLCM(uchar WDLCM);void WriteCommandLCM(uchar WCLCM,BuysC);uchar ReadStatusLCM(void);void LCMInit(void);void OutputInformation(uchar X, uchar Y, uchar DData);void DisplayListChar(uchar X, uchar Y, uchar code *DData);void Delay5Ms(void);void Delay400Ms(void);void systemsetup(void); //进入系统设置uchar code systemp[]={"System.setup"}; //字符串输出(系统设定)uchar code TIMER[]={"Time"}; //字符串输出(时间)uchar code DATE[]={"Date"}; //字符串输出(日期)uchar code alarmclock[]={"Clock"}; //字符串输出(闹铃)uchar code lamp[]={"Lamp"}; //字符串输出(背光灯)uchar code reset[]={"Reset"}; //字符串输出(时间归零)uchar code exit[]={"Exit"}; //字符串输出(退出)uchar code set[]={"Set"}; //字符串输出(设置)uchar code sec[]={"sec"}; //字符串输出(秒)uchar code ClockSet[]={"ClockSet"}; //字符串输出(闹铃设置)uchar code ClockOn[]={"ON"}; //字符串输出(ON)uchar code ClockOff[]={"OFF"}; //字符串输出(OFF)void timesetup(void); //时间设置void datesetup(void); //日期设置void alarmclockset(void); //闹铃设置void lampsetup(void); //背光灯设置void timereset(void); //时间清零/*******************************************************************/ void delay1(int ms){unsigned char y ;while(ms--){for(y = 0 ; y<250 ; y++){_nop_() ;_nop_() ;_nop_() ;_nop_() ;}}}void main(void){Speaker=1; //关闭蜂鸣器LED=0; //打开LED ,低电平有效,外接9012驱动Delay400Ms(); //启动等待,等LCM讲入工作状态Delay400Ms();LCMInit(); //LCM初始化TMOD=0x01; //16位定时TH0=0x3c; //50msTL0=0xb0;EA=1;TR0=1;ET0=1;while(1){if(TimerDown==0) //左移键按下后把背光灯打开{Delay5Ms();if(TimerDown==0){KeySound(); //蜂鸣声LED=0; //打开背光灯LedTime=R1302(0xc1)/16*10+R1302(0xc1)%16;} //取出背光灯时间并转换为十进制数}b=1; //模式键是否动作标志。
16 32点阵万年历加温度程序
/********************************************************* 程序名称:LED16*32万年历加温度简要说明:最大可显示16*16汉字P2口接上行线,P0口接下行线,P1口接扫描线编写:改编:huqihe*********************************************************/ #include <reg52.h>sbit cs1=P3^0;sbit cs2=P3^1;sbit k1 =P3^7;sbit k2 =P3^6;sbit k3 =P3^5;sbit k4 =P3^4;char mode,m;sbit DQ=P1^4; //ds18b20 端口int shi=12,fen=30,miao=0,ri=1,yue=12;int count;unsigned char ReadTemperature(void);void key(); //K1-K3按键扫描void shizhong();void wendudisplay();char code table[12][8]={{0xFF,0xFF,0x83,0x7D,0x7D,0x83,0xFF,0xFF},/*"0",0*/{0xFF,0xFF,0xBD,0x01,0xFD,0xFF,0xFF,0xFF},/*"1",1*/{0xFF,0xFF,0xB9,0x75,0x6D,0x9D,0xFF,0xFF},/*"2",2*/{0xFF,0xFF,0xBB,0x6D,0x6D,0x93,0xFF,0xFF},/*"3",3*/{0xFF,0xFF,0xE3,0x9B,0x01,0xFB,0xFF,0xFF},/*"4",4*/{0xFF,0xFF,0x0D,0x6D,0x6D,0x73,0xFF,0xFF},/*"5",5*/{0xFF,0xFF,0x83,0x6D,0x6D,0xB3,0xFF,0xFF},/*"6",6*/{0xFF,0xFF,0x3F,0x71,0x6F,0x1F,0xFF,0xFF},/*"7",7*/{0xFF,0xFF,0x93,0x6D,0x6D,0x93,0xFF,0xFF},/*"8",8*/{0xFF,0xFF,0x9B,0x6D,0x6D,0x83,0xFF,0xFF},/*"9",9*/{0xDB,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF},/*两点*/{0x3F,0x3F,0xFF,0xE3,0xDD,0xDD,0xDD,0xFF},/*oC*/};/************************************************************/ //显示秒char code table2[11][4]={{0xFF,0xC1,0xDD,0xC1},/*0*/{0xFF,0xFF,0xFF,0xC1},/*1*/{0xFF,0xD1,0xD5,0xC5},/*2*/{0xFF,0xD5,0xD5,0xC1},/*3*/{0xF3,0xEB,0xC1,0xFB},/*4*/{0xFF,0xC5,0xD5,0xD1},/*5*/{0xFF,0xC1,0xD5,0xD1},/*6*/{0xFF,0xDF,0xDF,0xC1},/*7*/{0xFF,0xC1,0xD5,0xC1},/*8*/{0xFF,0xC5,0xD5,0xC1},/*9*/{0xFF,0xF7,0xF7,0xF7},/*-*/};/************************************************************/ //延时函数void delay(int c){int i,j;for(i=0;i<c;i++)for(j=0;j<2;j++);}/************************************************************/ //时间中断函数50msvoid dingshi()interrupt 1{TH0=0X3C;TL0=0XB0;count++;if(count>=20){count=0;miao++;if(miao>=60){miao=0;fen++;if(fen>=60){fen=0;shi++;if(shi>=24){shi=0;ri++;if(ri==30){ri=0;yue++;if(yue>12)yue=1;}}}}}}/************************************************************/ //主函数void main(){TMOD=0x01;TH0=0X3C;TL0=0XB0;ET0=1;EA=1;TR0=1;while(1){if(k4==0){delay(15);if(k4==0){m=~ m;while(!k4);}}if(m){wendudisplay();}else{shizhong();}}}/************************************************************/ //时钟显示函数void shizhong(){int s,w,i;for(w=0;w<30;w++){ key();s=0;cs1=0;cs2=1;for(i=0;i<8;i++){P1=s;P0=0xff;P2=table[shi/10][i]; //小时的十位delay(8);P0=0xff;P2=0xff;s++;}for(i=0;i<8;i++){P1=s;P0=0xff;P2=table[shi%10][i]; //小时的个位delay(8);P0=0xff;P2=0xff;s++;}s=0;cs1=1;cs2=0;for(i=0;i<8;i++){P1=s;P0=0xff;P2=table[fen/10][i]; //分的十位delay(8);P0=0xff;P2=0xff;s++;}for(i=0;i<8;i++){P1=s;P0=0xff;P2=table[fen%10][i]; //分的个位delay(8);P0=0xff;P2=0xff;s++;}cs1=1;cs2=0;s=8;for(i=0;i<4;i++){P1=s;P2=0xff;P0=table2[miao/10][i]; //秒的十位delay(4);P0=0xff;P2=0xff;s++;}for(i=0;i<4;i++){P1=s;P2=0xff;P0=table2[miao%10][i]; //秒的个位delay(4);P0=0xff;P2=0xff;s++;}cs1=1;cs2=0;s=0;for(i=0;i<8;i++){P1=s;P0=0xff;P2=table[10][i]; // 两点delay(8);P0=0xff;P2=0xff;s++;}cs1=0;cs2=1;s=0;for(i=0;i<4;i++){P1=s;P2=0xff;P0=table2[yue/10][i]; // 月的十位delay(4);P0=0xff;P2=0xff;s++;}cs1=0;cs2=1;//s=4;for(i=0;i<4;i++){P1=s;P2=0xff;P0=table2[yue%10][i]; // 月的个位delay(4);P0=0xff;P2=0xff;s++;}cs1=0;cs2=1;s=8;for(i=0;i<4;i++){P1=s;P2=0xff;P0=table2[10][i]; // 一杠delay(4);P0=0xff;P2=0xff;s++;}cs1=0;cs2=1;s=12;for(i=0;i<4;i++){P1=s;P2=0xff;P0=table2[ri/10][i]; // 日的十位delay(4);P0=0xff;P2=0xff;s++;}cs1=1;cs2=0;s=0;for(i=0;i<4;i++){P1=s;P2=0xff;P0=table2[ri%10][i]; // 日的个位delay(4);P0=0xff;P2=0xff;s++;}}}/************************************************************/ //k1按键扫描void key(){if(k1==0){mode++;if(mode==6){mode=0;}while(!k1);}if(k2==0){delay(10);if(mode==1) //小时加1{shi++;if(shi==24){shi=0;}}if(mode==2) //分加1{fen++;if(fen==60)fen=0;}if(mode==3) //秒加1{miao++;if(miao==60)miao=0;}if(mode==4){ri++;if(ri==31) //日加1ri=1;}if(mode==5){yue++;if(yue==13) //月加1yue=1;}while(!k2);}if(k3==0){delay(10);if(mode==1) //小时减1{shi--;if(shi==0)shi=23;}delay(10);if(mode==2) //分减1 {fen--;if(fen==0)fen=59;}if(mode==3) //秒减1{miao--;if(miao==0)miao=59;}if(mode==4) //日减1{ri--;if(ri==0)ri=30;}if(mode==5) //月减1{yue--;if(yue==0)yue=12;}}}//延时函数void delayb(int c){while(c--);}void wendudisplay(){char s,i;char c_1602;int count;cs1=0;cs2=1;s= 0;for(i=0;i<8;i++){P1=s;P0=0xff;P2=table[c_1602/10][i]; //小时的十位delayb(20);P0=0xff;P2=0xff;s++;}for(i=0;i<8;i++){P1=s;P0=0xff;P2=table[c_1602%10][i]; //小时的个位delayb(20);P0=0xff;P2=0xff;s++;}cs1= 1;cs2 = 0;s = 0;for(i=0;i<8;i++){P1=s;P0=0xff;P2=table[11][i]; //小时的个位delayb(20);P0=0xff;P2=0xff;s++;}if(count ++ > 100){c_1602 = ReadTemperature();count = 0;}}void de_1802(char c){while(c--);}void Init_DS18B20(void){unsigned char x=0;DQ = 1; //DQ复位delayb(8); //稍做延时DQ = 0; //单片机将DQ拉低delayb(80); //精确延时大于480usDQ = 1; //拉高总线delayb(10);x=DQ; //稍做延时后如果x=0则初始化成功x=1则初始化失败delayb(5);}//读一个字节unsigned char ReadOneChar(void){unsigned char i=0;unsigned char dat = 0;for (i=8;i>0;i--){DQ = 0; // 给脉冲信号dat>>=1;DQ = 1; // 给脉冲信号if(DQ)dat|=0x80;delayb(5);}return(dat);}//写一个字节void WriteOneChar(unsigned char dat){unsigned char i=0;for (i=8; i>0; i--){DQ = 0;DQ = dat&0x01;delayb(5);DQ = 1;dat>>=1;}delayb(5);}//读取温度unsigned char ReadTemperature(void){unsigned char a=0;unsigned char b=0;unsigned char t=0;//float tt=0;Init_DS18B20();WriteOneChar(0xCC); // 跳过读序号列号的操作WriteOneChar(0x44); // 启动温度转换delayb(200);Init_DS18B20();WriteOneChar(0xCC); //跳过读序号列号的操作WriteOneChar(0xBE); //读取温度寄存器等(共可读9个寄存器)前两个就是温度a=ReadOneChar();b=ReadOneChar();b<<=4;b+=(a&0xf0)>>4;t=b;//tt=t*0.0625;//t= tt*10+0.5; //放大10倍输出并四舍五入return(t);}。
基于单片机的万年历与温度检测报警系统的程序
#include<reg52.h>#include<math.h>#include<INTRINS.H>#define uchar unsigned char#define uint unsigned int//各个IO口的初始化sbit dscs=P2^0;sbit dsas=P2^1;sbit dsrw=P2^2;sbit dsds=P2^3;sbit irq=P3^2;sbit s1=P3^0;sbit s2=P3^1;sbit s3=P3^2;sbit s4=P3^3;sbit beep=P1^0; sbit beep1=P1^1;sbit rs=P2^4;sbit rw=P2^5;sbit e=P2^6;sbit DQ=P1^7; int i,tt=0;uchar table0[]={"WELCOME !"};uchar table1[]={"HAVE A NICE DAY!"};uchar table2[]={"SET ALARM"};int miao,fen,shi,nian,yue,ri,week,s1num=0,num=0,num2=1,flag,flag_di,flag1,amiao,afen,ashi;uchar flag_get,num1,TZ=0;TX=0;keyxuan=1;uchar baiwei,shiwei,gewei,shifen,baifen,qianfen,wanfen;uint wd;void write_temperture(uchar TZ,uchar TX);void ReadTemperature();void DS18B20();unsigned char ReadOneChar();void WriteOneChar(unsigned char dat);void ddelay(unsigned int i);void dididi();void delay(uint z){uint x,y;for(x=z;x>0;x--)for(y=110;y>0;y--);}//液晶写数据与命令函数void write_com(uchar com){rs=0;rw=0;e=0;P0=com;delay(5);e=1;delay(5);e=0;}void write_date(uchar date){rs=1;rw=0;e=0;P0=date;delay(5);e=1;delay(5);e=0;}void init(){rw=0;write_com(0x38);write_com(0x0c);write_com(0x06);write_com(0x01); write_com(0x80);EA=1;EX0=1;IT0=1;TMOD=0x01;TH0=(65536-50000)/256;TL0=(65536-50000)%256;ET0=1;TR0=1;flag1=0;flag=0;flag_di=1;}DS12C887//读写数据与地址命令void write_ds(uchar add,uchar date){dscs=0;dsas=1;dsds=1;dsrw=1;P0=add;dsas=0;dsrw=0;P0=date;dsrw=1;dsas=1;dscs=1;}uchar read_ds(uchar add){uchards_date;dsas=1;dsds=1;dsrw=1;dscs=0;P0=add;dsas=0;dsds=0;P0=0xff;ds_date=P0;dsds=1;dsas=1;dscs=1;return ds_date; }void write_sfm(uchar add,uchar date)显示时分秒函数{ucharshi,ge;shi=date/10;ge=date%10;write_com(0x80+0x40+add);write_date(0x3 0+shi);write_date(0x30+ge);}void write_nyr(uchar add,uchar date)显示年月日函数{uchar shi,ge;shi=date/10;ge=date%10;write_com(0x80+add);write_date(0x30+shi);write_date(0x30+ge);}void didi()//闹钟报警程序{beep=0;delay(100);beep=1;delay(100);beep=0;delay(100);beep=1;}void dididi()//温度报警程序{beep1=0;delay(150);beep1=1;delay(150);beep1=0;delay(150);beep1=1;} void init_ds12c887()//DS12C887的初始化{write_ds(0x0a,0x20);write_ds(0x0b,0x26);}void read_alarm()//读取闹钟寄存器地址到相应的变量中{amiao=read_ds(1);afen=read_ds(3);ashi=read_ds(5);}void set_alarm(ashi,afen,amiao)//设置闹钟{write_ds(1,amiao);write_ds(3,afen);write_ds(5,ashi);}void showsign()//显示其他字符{ write_com(0x80);write_date('2');write_com(0x80+1);write_date('0'); write_com(0x80+4);write_date('-');write_com(0x80+7);write_date('-'); write_com(0x80+0x40+2);write_date(':');write_com(0x80+0x40+5);write_date(':');}void show_week()//显示星期函数{switch(week){case 1:write_com(0x80+11);write_date('M');write_date('O');write_date('N');write_date('D');write_date('A');break;case 2:write_com(0x80+11);write_date('T');write_date('U');write_date('E');write_date('S');write_date('D');break;case 3:write_com(0x80+11);write_date('W');write_date('E');write_date('N');write_date('D');write_date('N');break;case 4:write_com(0x80+11);write_date('T');write_date('H');write_date('U');write_date('R');write_date('S');break;case 5:write_com(0x80+11);write_date('F');write_date('R');write_date('I');write_date('D');write_date('A');break;case 6:write_com(0x80+11);write_date('S');write_date('A');write_date('T');write_date('T');write_date('U');break;case 7:write_com(0x80+11);write_date('S');write_date('U'); write_date('N');write_date('D');write_date('A');break;}}void keyscan()//键盘扫描{if(s1==0){delay(4);if(s1==0){s1num++;if(flag1==1){if(s1num==8){s1num=1;}}keyxuan=0; flag=1;// 温度扫描和时钟显示标志位设为无效while(!s1);switch(s1num)//选择液晶光标位置{case 1:write_com(0x80+0x40+7);write_com(0x0f);break;case 2:write_com(0x80+0x40+4);write_com(0x0f);break;case 3:write_com(0x80+0x40+1);write_com(0x0f);break;case 4:write_com(0x80+15);write_com(0x0f);break;case 5:write_com(0x80+9);write_com(0x0f);break;case 6:write_com(0x80+6);write_com(0x0f);break;case 7:write_com(0x80+3);write_com(0x0f);break;case 8:write_ds(0x00,miao);delay(5);//最后一次将修改后的数据读取到相应的寄存器中write_ds(0x02,fen);delay(5);write_ds(0x04,shi);delay(5);write_ds(0x06,week);delay(5);write_ds(0x07,ri);delay(5);write_ds(0x08,yue);delay(5);write_ds(0x09,nian);delay(5);flag=0;keyxuan=1;write_com(0x0c);s1num=0;break;}}}//在推出键盘扫描程序前将相应标志位设置为有效,并发出清屏命令if(s1num!=0){if(s2==0){delay(4);if(s2==0){while(!s2);switch(s1num){case 1:miao++;if(miao==60)miao=0;write_sfm(6,miao);write_com(0x80+0x40+7);break;case 2:fen++;if(fen==60)fen=0;write_sfm(3,fen);write_com(0x80+0x40+4);break;case 3:shi++;if(shi==24)shi=0;write_sfm(0,shi);write_com(0x80+0x40+1);break;case 4:week++;if(week==8)week=1;show_week();break;case 5:ri++;if(ri==32)ri=1;write_nyr(8,ri);write_com(0x80+9);break;case 6:yue++;if(yue==13)yue=1;write_nyr(5,yue);write_com(0x80+6);break;case 7:nian++;if(nian==100)nian=0;write_nyr(2,nian);write_com(0x80+3);break;}}}}if(s1num!=0){if(s3==0){delay(4);if(s3==0){while(!s3);switch(s1num){case 1:miao--;if(miao==-1)miao=59;write_sfm(6,miao);write_com(0x80+0x40+7);break;case 2:fen--;if(fen==-1)fen=59;write_sfm(3,fen);write_com(0x80+0x40+4);break;case3:shi--;if(shi==-1)shi=23;write_sfm(0,shi);write_com(0x80+0x40+1);break;case 4:week--;if(week==0)week=7;show_week();break;case 5:ri--;if(ri==-1)ri=31;write_nyr(8,ri);write_com(0x80+9);break; case 6:yue--;if(yue==0)yue=12;write_nyr(5,yue);write_com(0x80+6);break;case7:nian--;if(nian==-1)nian=99;write_nyr(2,nian);write_com(0x80+3); break;}}}}if(s1num!=0){if(s4==0){delay(4);if(s4==0)//进入闹钟设置程序{num++;while(!s4);keyxuan=0;if(num==1){flag1=1;write_com(0x80);for(i=0;i<16;i++){write_date(' ');delay(5);}write_com(0x0f);write_com(0x80+3);for(i=0;i<10;i++){write_date(table2[i]);delay(2);} read_alarm();miao=amiao;fen=afen;shi=ashi;write_sfm(0,ashi);write_com(0x80+0x40+1);write_sfm(3,afen);write_com(0x80+0x40+4);write_sfm(6,amiao);write_com(0x80+0x40+7);}if(num==2){num=0;s1num=0;write_com(0x80+3);for(i=0;i<10;i++){write_date(' ');delay(5);}amiao=miao;afen=fen;ashi=shi;set_alarm(ashi,afen,amiao);flag=0;flag1=0;write_com(0x0c);keyxuan=1;}}}}}//推出闹钟设置程序,将修改后的数据读取到相应寄存器中,并将相应标志位设置为有效,发出清屏命令。
基于单片机带温度显示的液晶万年历
摘要在寒假期间我用一周时间完成了这个液晶万年历,它可以显示年月日、时分秒、以及温度(可上下限报警),可以对时间进行加一或减一调整,并加入了闰、平年时间调整,方便可行,已经调试成功。
考虑到成本和方便,本作品采用了STC89c52和DS18B20,计时用的是51单片机自带的十六位定时器/计数器T0,尽管对时间进行了误差调整但是还是有一定的误差,考虑到学校后改用DS1302时钟芯片,进一步减小误差。
温度显示精度达到0.1摄氏度。
关键词:单片机 DS18B20 万年历温度1.硬件工作介绍(1)上电自动复位及手动复位电路STC89c52单片机的RST端外部复位有两种操作方式:上电自动复位和按键手动复位。
本设计用上电自动复位以及手动复位下结合的方式外接电路(见附图)。
(2)时钟振荡电路作品中采用12M晶振,其连接方法如图所示,其中电容的值都为22pF。
(3)1602液晶显示接口1602采用标准的16脚接口(见附图),其中:第1脚:GND为地电源第2脚:VCC接5V正电源第3脚:V0为液晶显示器对比度调整端,接正电源时对比度最弱,接地电源时对比度最高,对比度过高时会产生“鬼影”,使用时可以通过一个10K的电位器调整对比度第4脚:RS为寄存器选择,高电平时选择数据寄存器、低电平时选择指令寄存器。
第5脚:RW为读写信号线,高电平时进行读操作,低电平时进行写操作。
当RS 和RW共同为低电平时可以写入指令或者显示地址,当RS为低电平RW为高电平时可以读忙信号,当RS为高电平RW为低电平时可以写入数据。
第6脚:E端为使能端,当E端由高电平跳变成低电平时,液晶模块执行命令。
第7~14脚:D0~D7为8位双向数据线。
第15脚:VCC第16:GND(4)键盘键盘是通过S3(P3.2),S4(p3.3),S5(p3.4)对时钟进行调整,其S3选择要调整的对象如时,分,日,月等等,并在液晶屏上显示所选的对象。
S4对所选中的对象进行加一调整,而S5对所选对象进行减一调整。
单片机万年历 时钟 闹钟 温度程序..
#define uint unsigned int
sbit DQ=P2^3;
sbit L=P1^4;
sbit DZ=P3^5;//这是用于控制数码管关闭,这个数码管和液晶同时亮所需电流大,单片机难驱动
sbit rs=P2^5;
sbit rw=P2^6;
ge=date%10;
write_com(0x80+0x40+add);
write_date(0x30+shi);
write_date(0x30+ge);
}
//第一行
void write_sfr(uchar ad,uchar da)
{
uchar x,y;
x=da/10;
y=da%10;
write_com(0x80+ad);
{
lcden=0;
rs=1;
rw=0;
P0=dat;
delay(5);lBiblioteka den=1;delay(5);
lcden=0;
}
//初始化函数
//**************************************************
void init()
{
L=1;
jd=0;
DZ=1;
P0=0XFF;
//延时函数,在12MHz的晶振频率下延时1ms
//************************************************
void delay(uint t)
{
uchar x,y;
for(x=t;x>0;x--)
1602显示温度+万年历
程序功能:1602显示温度、时间(简称万年历)废话不多说,先上图希望大家多多捧场#include<reg51.h>#include<lcd1602.h>//#include<keyscan.h>#include<ds1302.h>#define uchar unsigned char#define uint unsigned intuchar init_time[]={21,50,30,11,12,31,6}; //23:59:30 11-12-31 6 uchar current_time[]={0,0,0,0,0,0,0};uchar num=0;sbit up=P1^1;sbit donw=P1^2;sbit set=P1^3;void read_current_time() //读取当前时间{current_time[2]=read_1302(0x81);current_time[1]=read_1302(0x83);current_time[0]=read_1302(0x85);current_time[3]=read_1302(0x8d);current_time[4]=read_1302(0x89);current_time[5]=read_1302(0x87);}void write_hour_min_sec(uchar add,uchar date) //时分秒{uchar s,g;s=date/16;g=date%16;lcd_wcom(0x80+0x40+add);lcd_wdat(0x30+s);lcd_wdat(0x30+g);}void write_yea_mon_dat(uchar add,uchar date) //年月日{uchar s,g;s=date/16;g=date%16;lcd_wcom(0x80+add);lcd_wdat(0x30+s);lcd_wdat(0x30+g);}void dis_dat_1602() //显示{lcd_wcom(0x80);lcd_wdat('2');lcd_wdat('0');write_yea_mon_dat(2,current_time[3]);lcd_wdat('-');write_yea_mon_dat(5,current_time[4]);lcd_wdat('-');write_yea_mon_dat(8,current_time[5]);lcd_wcom(0x80+11);lcd_wdat('W');lcd_wdat('e');lcd_wdat('e');lcd_wdat('k');write_hour_min_sec(0,current_time[0]);lcd_wdat(':');write_hour_min_sec(3,current_time[1]);lcd_wdat(':');write_hour_min_sec(6,current_time[2]);}void delay(uint z) //延时函数{uint x,y;for(x = z;x>0;x--)for(y = 124;y>0;y--);}void keyscan(){if(set==0) //判断按键是否按下{delay(5); //消除抖动if(set==0){num++;if(num==7){num=0;current_time[2]=0;write_1302(0x8e,0x00);write_1302(0x80,current_time[2]);write_1302(0x8e,0x80);}}if(up==0){delay(5);if(up==0){while(!up); //一直检测,直到up=1if(num==1){// lcd_wcom(0x80+0x44);// lcd_wcom(0x0e); //光标闪烁// lcd_wdat(current_time[1]);current_time[1]=read_1302(0x83);current_time[1]++;if(current_time[1]&0x0f>9)current_time[1]=current_time[1]+6;if(current_time[1]>=60)current_time[1]=0x00;write_1302(0x8e,0x80);write_1302(0x82,current_time[1]);write_1302(0x8e,0x80);}}}}}void main(){uchar i,d;TMOD=0x01;TH0=0xfc;TL0=0x18;EA=1;ET0=1;TR0=1;for(i=0;i<7;i++) //十进制转BCD码{d=init_time[i]/10;init_time[i]=init_time[i]%10;init_time[i]=init_time[i]+d*16;}write_1302(0x8e,0x00);write_1302(0x80,init_time[2]);write_1302(0x82,init_time[1]);write_1302(0x84,init_time[0]);write_1302(0x86,init_time[5]);write_1302(0x88,init_time[4]);write_1302(0x8a,init_time[6]);write_1302(0x8c,init_time[3]);write_1302(0x8e,0x80);lcd_init();while(1){dis_dat_1602();read_current_time();}}void timer0() interrupt 1{TH0=0xfc;TL0=0x18;keyscan();}#ifndef __lcd1602_H__#define __lcd1602_H__#include<reg51.h>#include<intrins.h>#define uchar unsigned char#define uint unsigned intsbit rs=P2^6;sbit rw=P2^5;sbit en=P2^7;void delayled(int n){int x,y;for(x=n;x>0;x--){for(y=110;y>0;y--);}}void lcd_wcom(uchar com){rs=0;rw=0;P0=com;delayled(5);en=1;en=0;}void lcd_wdat(uchar dat){rs=1;rw=0;P0=dat;delayled(5);en=1;en=0;}void lcd_init(){lcd_wcom(0x38);lcd_wcom(0x0c);lcd_wcom(0x06);lcd_wcom(0x01);}#endif#ifndef __ds1302_H__#define __ds1302_H__#include<reg51.h>#define uchar unsigned char#define uint unsigned intsbit rst=P3^5;sbit sclk=P3^6;sbit io=P3^4;//写入一个字节到DS1302void write_byte_1302(uchar temp){uchar i;for(i=0;i<8;i++){sclk=0;io=temp&0x01;temp>>=1;sclk=1;}}//写入到DS1302void write_1302(uchar address,uchar dat) {rst=0;sclk=0;rst=1;write_byte_1302(address);write_byte_1302(dat);rst=0;sclk=0;sclk=1;io=1;}//读出ds1302数据uchar read_1302(uchar address){uchar i,temp;rst=0;sclk=0;rst=1;write_byte_1302(address);for(i=0;i<8;i++){sclk=0;temp>>=1;if(io==1)temp|=0x80;sclk=1;}rst=0;sclk=0;sclk=1;io=0;io=1;return temp;}#endif#ifndef __keyscan_H__#define __keyscan_H__#include<reg51.h>#include<ds1302.h>#include<lcd1602.h>#define uchar unsigned char#define uint unsigned intuchar current_time[]={0,0,0,0,0,0,0};void delay(uint z) //延时函数{uint x,y;for(x = z;x>0;x--)for(y = 124;y>0;y--);}void keyscan(){uchar num;if(set==0) //判断按键是否按下{delay(5); //消除抖动if(set==0){num++;if(num==7){num==0;current_time[2]=0;write_1302(0x8e,0x00);write_1302(0x80,current_time[2]);write_1302(0x8e,0x80);}}if(up==0){delay(5);if(up==0){while(!up); //一直检测,直到up=1if(num==1){lcd_wcom(0x80+0x44);lcd_wcom(0x0e); //光标闪烁lcd_wdat(current_time[1]);current_time[1]=read_1302(0x83);current_time[1]++;if(current_time[1]&0x0f>9)current_time[1]=current_time[1]+6;if(current_time[1]>=60)current_time[1]=0x00;write_1302(0x8e,0x80);write_1302(0x82,current_time[1]);write_1302(0x8e,0x80);}}}}}#endif。
温度万年历(附电路图和程序)
240x128温度万年历主界面:MCU方面电路图,单片机用的是STC89S52不是图上的C55显示界面和开机界面:附带程序为了方便大家,程序文件复制出来就可以使用了!main.cdelay.h ds18b20.h ds1302.h ENG.h HANZI.h LM4229.h PIC.h仿真文件:240x128.DSN也可以参考下面,程序都是模块化程序!如下图://main.c#include<reg52.h>#include"LM4229.h"#include"ds18b20.h"#include"delay.h"#include"ds1302.h"unsigned intTempH,TempL,temp;//温度相关参数unsigned char tab_wendu[5];////////////////////显示日期时间////////////////////////////////////////////////voiddisplay_time(void){//年Display8x16(0,8,time_buf1[1]/10+0x30);Display8x16(0,9,time_buf1[1]%10+0x30);//月Display8x16(0,12,time_buf1[2]/10+0x30);Display8x16(0,13,time_buf1[2]%10+0x30);//日Display8x16(0,16,time_buf1[3]/10+0x30);Display8x16(0,17,time_buf1[3]%10+0x30);//时Display8x16(20,6,time_buf1[4]/10+0x30);Display8x16(20,7,time_buf1[4]%10+0x30);//分Display8x16(20,9,time_buf1[5]/10+0x30);Display8x16(20,10,time_buf1[5]%10+0x30);//秒Display8x16(20,12,time_buf1[6]/10+0x30);Display8x16(20,13,time_buf1[6]%10+0x30);switch(time_buf1[7]%10){case 2: LcdPrint(0,26,"一"); break;case 3: LcdPrint(0,26,"二"); break;case 4: LcdPrint(0,26,"三"); break;case 5: LcdPrint(0,26,"四"); break;case 6: LcdPrint(0,26,"五"); break;case 7: LcdPrint(0,26,"六"); break;case 1: LcdPrint(0,26,"日"); break;default: break;}}/*----------------------------------------------------------------------主函数----------------------------------------------------------------------*/ void main( ){unsigned char i;Lcd_Init();//屏幕初始化ClrScr(); //清屏ds1302_init();//时钟芯片初始化//ds1302_write_time();//初次使用写入初次设定值Show128x240(kiss);LcdPrint(90,9,"Startting...");LcdPrint(112,0,"------------------------------");for(i=0;i<30;i++){LcdPrint(112,i,">");delay_us(600);}ClrScr(); //清屏LcdPrint(54,4,"Welcome To Real Time!");delay_us(60000);ClrScr(); //清屏LcdPrint(0,0,"日期:20 年月日星期"); LcdPrint(20,0,"时间:: :");LcdPrint(40,0,"温度:℃");LcdPrint(80,0,"人生格言:");LcdPrint(100,0,"当今世界,舍我其谁!");while(1){////////////////时间显示//////////////////////// ds1302_read_time();//读取时钟信息display_time();//显示时间////////////////温度显示//////////////////////// temp=ReadTemperature();//读取温度if(temp&0x8000){tab_wendu[0]='-' ; //负号标志到时候加上temp=~temp; // 取反加1temp +=1;}elsetab_wendu[0]= TempH/100+0x30;TempH=temp>>4;TempL=temp&0x0F;TempL=TempL*6/10;//小数近似处理tab_wendu[1]= TempH/10%10+0x30;tab_wendu[2]= TempH%10+0x30;tab_wendu[3]='.';tab_wendu[4]=TempL+0x30;LcdPrint(40,6,tab_wendu);//显示温度delay_ms(100);}}//delay.h#ifndef __DELAY_H__#define __DELAY_H__/*------------------------------------------------uS延时函数,含有输入参数unsigned char t,无返回值unsigned char 是定义无符号字符变量,其值的范围是0~255 这里使用晶振12M,精确延时请使用汇编,大致延时长度如下T=tx2+5 uS------------------------------------------------*/voiddelay_us(unsigned char t);/*------------------------------------------------mS延时函数,含有输入参数unsigned char t,无返回值unsigned char 是定义无符号字符变量,其值的范围是0~255 这里使用晶振12M,精确延时请使用汇编------------------------------------------------*/voiddelay_ms(unsigned char t);voiddelay_us(unsigned char t){while(--t);}voiddelay_ms(unsigned char t){while(t--){//大致延时1mSdelay_us(245);delay_us(245);}}#endif//ds18b20.h#ifndef __DS18B20_H__#define __DS18B20_H__#include<reg52.h> //包含头文件,一般情况不需要改动,头文件包含特殊功能寄存器的定义#include"delay.h"/*------------------------------------------------端口定义------------------------------------------------*/sbit DQ=P3^6;//ds18b20端口/*------------------------------------------------函数声明------------------------------------------------*/unsignedintReadTemperature(void);bit Init_DS18B20(void);unsigned char ReadOneChar(void);voidWriteOneChar(unsigned char dat);/*------------------------------------------------18b20初始化------------------------------------------------*/bit Init_DS18B20(void){bitdat=0;DQ = 1; //DQ复位delay_us(5); //稍做延时DQ = 0; //单片机将DQ拉低delay_us(200); //精确延时大于480us 小于960usdelay_us(200);DQ = 1; //拉高总线delay_us(50); //15~60us 后接收60-240us的存在脉冲dat=DQ; //如果x=0则初始化成功, x=1则初始化失败delay_us(25); //稍作延时返回returndat;}/*------------------------------------------------读取一个字节------------------------------------------------*/unsigned char ReadOneChar(void){unsigned char i=0;unsigned char dat = 0;{DQ = 0; // 给脉冲信号dat>>=1;DQ = 1; // 给脉冲信号if(DQ)dat|=0x80;delay_us(25);}return(dat);}/*------------------------------------------------ 写入一个字节------------------------------------------------*/ voidWriteOneChar(unsigned char dat) {unsigned char i=0;for (i=8; i>0; i--){DQ = 0;DQ = dat&0x01;delay_us(25);DQ = 1;dat>>=1;delay_us(25);}/*------------------------------------------------读取温度------------------------------------------------*/unsignedintReadTemperature(void){unsigned char a=0;unsignedint b=0;unsignedint t=0;Init_DS18B20();WriteOneChar(0xCC); // 跳过读序号列号的操作WriteOneChar(0x44); // 启动温度转换delay_ms(10);Init_DS18B20();WriteOneChar(0xCC); //跳过读序号列号的操作WriteOneChar(0xBE); //读取温度寄存器等(共可读9个寄存器)前两个就是温度a=ReadOneChar(); //低位b=ReadOneChar(); //高位b<<=8;return(t);}#endif//eng.h#ifndefdata_h#define data_hchar code ASC_MSK[96*16] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*-- --*/0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x3C,0x3C,0x3C,0x18, /*-- ! --*/ 0x18,0x00,0x18,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x66,0x66,0x66,0x00,0x00, /*-- " --*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x36,0x36,0x7F,0x36,0x36, /*-- # --*/ 0x36,0x7F,0x36,0x36,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x3C,0x66,0x60,0x30,0x18, /*-- $ --*/ 0x0C,0x06,0x66,0x3C,0x18,0x18,0x00,0x00,0x00,0x00,0x70,0xD8,0xDA,0x76,0x0C,0x18, /*-- % --*/ 0x30,0x6E,0x5B,0x1B,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x18,0x00,0x00, /*-- ' --*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x18,0x18,0x30,0x30, /*-- ( --*/ 0x30,0x30,0x30,0x18,0x18,0x0C,0x00,0x00,0x00,0x00,0x00,0x30,0x18,0x18,0x0C,0x0C, /*-- ) --*/ 0x0C,0x0C,0x0C,0x18,0x18,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x36,0x1C,0x7F, /*-- * --*/ 0x1C,0x36,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x7E, /*-- + --*/ 0x18,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*-- , --*/ 0x00,0x00,0x1C,0x1C,0x0C,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7E, /*-- - --*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*-- . --*/ 0x00,0x00,0x1C,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x06,0x0C,0x0C,0x18, /*-- / --*/ 0x18,0x30,0x30,0x60,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x1E,0x33,0x37,0x37,0x33, /*-- 0 --*/ 0x3B,0x3B,0x33,0x1E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x1C,0x7C,0x0C,0x0C, /*-- 1 --*/ 0x0C,0x0C,0x0C,0x0C,0x00,0x00,0x00,0x00,0x06,0x66,0x66,0x3C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x36,0x36,0x36, /*-- 4 --*/ 0x66,0x7F,0x06,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0x60,0x60,0x60,0x7C, /*-- 5 --*/ 0x06,0x06,0x0C,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x18,0x30,0x7C,0x66, /*-- 6 --*/ 0x66,0x66,0x66,0x3C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0x06,0x0C,0x0C,0x18, /*-- 7 --*/ 0x18,0x30,0x30,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x66,0x66,0x76,0x3C, /*-- 8 --*/ 0x6E,0x66,0x66,0x3C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x66,0x66,0x66,0x66, /*-- 9 --*/ 0x3E,0x0C,0x18,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x1C,0x00, /*-- : --*/ 0x00,0x00,0x1C,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x1C,0x00, /*-- ; --*/ 0x00,0x00,0x1C,0x1C,0x0C,0x18,0x00,0x00,0x00,0x00,0x00,0x06,0x0C,0x18,0x30,0x60, /*-- < --*/ 0x30,0x18,0x0C,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0x00, /*-- = --*/ 0x7E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x18,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0xC3,0xC3,0xCF,0xDB, /*-- @ --*/ 0xDB,0xCF,0xC0,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x3C,0x66,0x66,0x66, /*-- A --*/ 0x7E,0x66,0x66,0x66,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x66,0x66,0x66,0x7C, /*-- B --*/ 0x66,0x66,0x66,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x66,0x66,0x60,0x60, /*-- C --*/ 0x60,0x66,0x66,0x3C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x6C,0x66,0x66,0x66, /*-- D --*/ 0x66,0x66,0x6C,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0x60,0x60,0x60,0x7C, /*-- E --*/ 0x60,0x60,0x60,0x7E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0x60,0x60,0x60,0x7C, /*-- F --*/ 0x60,0x60,0x60,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x66,0x66,0x60,0x60, /*-- G --*/ 0x6E,0x66,0x66,0x3E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x66,0x66,0x66,0x66,0x7E, /*-- H --*/ 0x66,0x66,0x66,0x66,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x18,0x18,0x18,0x18, /*-- I --*/ 0x18,0x18,0x18,0x3C,0x00,0x00,0x00,0x00,0x6C,0x6C,0x66,0x66,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x60,0x60,0x60,0x60, /*-- L --*/ 0x60,0x60,0x60,0x7E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x63,0x63,0x77,0x6B,0x6B, /*-- M --*/ 0x6B,0x63,0x63,0x63,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x63,0x63,0x73,0x7B,0x6F, /*-- N --*/ 0x67,0x63,0x63,0x63,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x66,0x66,0x66,0x66, /*-- O --*/ 0x66,0x66,0x66,0x3C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x66,0x66,0x66,0x7C, /*-- P --*/ 0x60,0x60,0x60,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x66,0x66,0x66,0x66, /*-- Q --*/ 0x66,0x66,0x66,0x3C,0x0C,0x06,0x00,0x00,0x00,0x00,0x00,0x7C,0x66,0x66,0x66,0x7C, /*-- R --*/ 0x6C,0x66,0x66,0x66,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x66,0x60,0x30,0x18, /*-- S --*/ 0x0C,0x06,0x66,0x3C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0x18,0x18,0x18,0x18, /*-- T --*/ 0x18,0x18,0x18,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x66,0x66,0x66,0x66,0x66, /*-- U --*/ 0x66,0x66,0x66,0x3C,0x00,0x00,0x00,0x00,0x6B,0x36,0x36,0x36,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x66,0x66,0x34,0x18,0x18, /*-- X --*/ 0x2C,0x66,0x66,0x66,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x66,0x66,0x66,0x66,0x3C, /*-- Y --*/ 0x18,0x18,0x18,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0x06,0x06,0x0C,0x18, /*-- Z --*/ 0x30,0x60,0x60,0x7E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x30,0x30,0x30,0x30, /*-- [ --*/ 0x30,0x30,0x30,0x30,0x30,0x30,0x3C,0x3C,0x00,0x00,0x00,0x60,0x60,0x30,0x30,0x18, /*-- \ --*/ 0x18,0x0C,0x0C,0x06,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x0C,0x0C,0x0C,0x0C, /*-- ] --*/ 0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x3C,0x3C,0x00,0x18,0x3C,0x66,0x00,0x00,0x00,0x00, /*-- ^ --*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*-- _ --*/ 0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0x00,0x38,0x18,0x0C,0x00,0x00,0x00,0x00, /*-- ` --*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x06,0x06, /*-- a --*/ 0x3E,0x66,0x66,0x3E,0x00,0x00,0x00,0x00,0x60,0x60,0x66,0x3C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x06,0x3E,0x66,0x66, /*-- d --*/ 0x66,0x66,0x66,0x3E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x66,0x66, /*-- e --*/ 0x7E,0x60,0x60,0x3C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1E,0x30,0x30,0x30,0x7E, /*-- f --*/ 0x30,0x30,0x30,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3E,0x66,0x66, /*-- g --*/ 0x66,0x66,0x66,0x3E,0x06,0x06,0x7C,0x7C,0x00,0x00,0x00,0x60,0x60,0x7C,0x66,0x66, /*-- h --*/ 0x66,0x66,0x66,0x66,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x78,0x18,0x18, /*-- i --*/ 0x18,0x18,0x18,0x7E,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x0C,0x00,0x3C,0x0C,0x0C, /*-- j --*/ 0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x78,0x78,0x00,0x00,0x00,0x60,0x60,0x66,0x66,0x6C, /*-- k --*/ 0x78,0x6C,0x66,0x66,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x18,0x18,0x18,0x18, /*-- l --*/ 0x18,0x18,0x18,0x7E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0x6B,0x6B, /*-- m --*/ 0x6B,0x6B,0x6B,0x63,0x00,0x00,0x00,0x00,0x66,0x66,0x66,0x3C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x66,0x66, /*-- p --*/ 0x66,0x66,0x66,0x7C,0x60,0x60,0x60,0x60,0x00,0x00,0x00,0x00,0x00,0x3E,0x66,0x66, /*-- q --*/ 0x66,0x66,0x66,0x3E,0x06,0x06,0x06,0x06,0x00,0x00,0x00,0x00,0x00,0x66,0x6E,0x70, /*-- r --*/ 0x60,0x60,0x60,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3E,0x60,0x60, /*-- s --*/ 0x3C,0x06,0x06,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x7E,0x30,0x30, /*-- t --*/ 0x30,0x30,0x30,0x1E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x66,0x66,0x66, /*-- u --*/ 0x66,0x66,0x66,0x3E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x66,0x66,0x66, /*-- v --*/ 0x66,0x66,0x3C,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x63,0x6B,0x6B, /*-- w --*/ 0x6B,0x6B,0x36,0x36,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x66,0x66,0x3C, /*-- x --*/ 0x18,0x3C,0x66,0x66,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x66,0x66,0x66, /*-- y --*/ 0x66,0x66,0x66,0x3C,0x0C,0x18,0xF0,0xF0,0x60,0x30,0x18,0x18,0x18,0x0C,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x18,0x18,0x18, /*-- | --*/0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x00,0x00,0x00,0x30,0x18,0x18,0x18,0x0C, /*-- } --*/0x06,0x0C,0x18,0x18,0x18,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x71,0xDB, /*-- ~ --*/0x8E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*-- . --*/0x00,0x00,0x1C,0x1C,0x00,0x00,0x00,0x00};#endif//pic.hconst unsigned char code kiss[]={/*-- 调入了一幅图像:C:\Documents and Settings\Administrator\桌面\未标题-2.bmp --*//*-- 宽度x高度=240x128 --*/0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xF F,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0xF8,0x0 0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xFF,0xFE,0x00,0x00,0x0 0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xFF,0xFE,0x00,0x00,0x00,0x00,0x0 0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x0 0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,00,0x00,0x00,0xFF,0xFF,0xFC,0x78,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0 0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0xFF,0xFF,0xFC,0xFE,0x00,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0 0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xFF,0xF F,0xFC,0xFF,0xFF,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0 0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xFF,0xFF,0xF8,0xF F,0xFF,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xFF,0xFF,0xF8,0xFF,0xFF,0xFC ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xFF,0xFF,0xF1,0xFF,0xFF,0xF8,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x03,0xFF,0xFF,0xF1,0xFF,0xFF,0xF8,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x03,0xFF,0xFF,0xF1,0xFF,0xFF,0xF8,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x07,0xFF,0xFF,0xF1,0xFF,0xFF,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 07,0xFF,0xFF,0xE3,0xFF,0xFF,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xFF,0xF F,0xE3,0xFF,0xFF,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0 0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xFF,0xFF,0xE7,0xF F,0xFF,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x00,0x07,0xC7,0xFF,0xFF,0xE0,0x00,0x0 0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xC7,0xFF,0xFF,0xE0,0x00,0x00,0x00,0x0 0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x7F,0xC0,0xCF,0xFF,0xFF,0xE0,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x03,0xFF,0xF8,0x0F,0xFF,0xFF,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 1F,0xFF,0xFC,0x0F,0xFF,0xFF,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0 0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xFF,0xF F,0x0F,,0xFF,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0xFF,0x00,0xFF,0xFC,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0xFF,0x10,0x1F,0xE0,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0xFF,0x3C,0x00,0x01,0x00,0x00,0x00,0x00,0x0 0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x7F,0xFF,0xFF,0x3F,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x7F,0xFF,0xFE,0x3F,0xF1,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0xFE,0x7F,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0 0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xF E,0x7F,0xFF,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0 0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFC,0x7F,0xFF ,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFC,0xFF,0xFF,0xFE,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xFF,0xFF,0xFC,0xFF,0xFF,0xFE,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x01,0xFF,0xFF,0xFC,0xFF,0xFF,0xFC,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x01,0xFF,0xFF,0xF9,0xFF,0xFF,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x FF,0xFF,0xF9,0xFF,0xFF,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0 0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xFF,0xFF,0xF 1,0xFF,0xFF,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0 0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xE0,0x07,0xF3,0xFF,0xF F,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0xF3,0xFF,0xFF,0xF8,0x0 0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x73,0xFF,0xFF,0xF0,0x00,0x00,0x0 0,0x00,0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x07,0xFF,0xFF,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x0 0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x03,0xFF,0xFF,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0 0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x01,0xFF,0xFF,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0 0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0xFF,0xFF,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0 0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xF C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,。
DSHELCD实现万年历和温度显示(不用时间芯片)
#include<reg52.h>#include<intrins.h>#include <math.h>#define uchar unsigned char#define uint unsigned intuchar code table[]="--Figo"。
//uchar code table1[]=""。
sbit lcden=P3^4。
sbit lcdrs=P3^5。
sbit dula=P2^6。
sbit wela=P2^7。
sbit ds=P1^7。
sbit key1=P1^0。
sbit key2=P1^1。
sbit key3=P1^2。
sbit key4=P1^3。
int tempValue。
int s_1=1000。
unsigned char FunKeyFlag=6,keypress。
#define key_vaule1 0x01#define key_vaule2 0x02#define key_vaule3 0x03#define key_vaule4 0x04uchar num。
int ms_10=10。
int flag=0。
int s_1_1=1000。
uint sec=55。
uint min=9。
uint hour=22。
uint nian=2014。
uint yue=8。
uint ri=20。
uint xingqi=3。
//延时函数, 对于11.0592MHz时钟, 例i=10,则大概延时10ms. void delay_wendu(unsigned int i){unsigned int j。
while(i--){for(j = 0。
j < 125。
j++)。
}}//初始化DS18B20//让DS18B20一段相对长时间低电平, 然后一段相对非常短时间高电平, 即可启动void dsInit(){//对于11.0592MHz时钟, unsigned int型的i, 作一个i++操作的时间大于?usunsigned int i。
带温度显示的万年历 数码管显示
设计报告万年历时钟的设计班级: 09光电<2>班专业:光电子技术姓名:阮军峰学号: 0906010234 完成日期:2011年06月11日一、设计目的:1、掌握C51程序用于实践并实现相应的功能;2、掌握时钟程序的使用方法;3、掌握时间函数的使用方法;4、掌握键盘的程序使用方法;二、设计任务:设计一个智能化万年历时钟电路,LED数码管作为电路的显示部分,按钮开关作为调时部分,通过与单片机连接数码管动态显示年、月、日、时、分、秒、星期、温度。
并能准确计算闰年闰月的显示。
三、设计要求:通过与单片机连接数码管动态显示年、月、日、时、分、秒、星期等功能,并能准确计算闰年闰月的显示,三个个按钮连接P3.0、P3.1、P3.2可以精确调整每一个时间数值,通过对所设计的万年历时钟电路进行实验测试,达到了动态显示时间,随时调整时间等技术指标。
四、系统方案设计:1、系统总体设计:1) 原理构成框图本设计用STC89C51作为核心控制部分,外接晶振电路和74HC154,74LS138作为位选扩展电路,P3.0、 P3.1 、P3.2接三个个按钮作为时间调整部分,以两个17个数码管作为显示部分,P2口作为位选,P0口作为数据输出部分。
具体框图如图1所示:图1 原理框图2) 主程序的设计系统程序采用C语言按模块化方式进行设计,然后通过KeilC51L 软件开发平台将程序转变成十六进制程序语言,得到HEX文件,接着使用Proteous进行仿真,其次,按照Proteous的仿真电路图,在Protel99SE中完成电路板的逻辑布局及布线。
3) 时间调整电路的设计采用按键设计,独立式按键直接与单片机I/O口相连构成键盘,每个按键不会相互影响,按下模式可以选择年月日时分秒星期。
按下(+)(-)进行调试,程序如下:while(1){P3_0=1;if(P3_0==0){delay(10);if(P3_0==0)//如果按键被按下{Kdelay();if(P3_0==0)//确定按键按下{while(P3_0==0); // 等待按键放开cursor++;if(cursor>=9){cursor=0;}//如果cursor大于9则cursor=0if(P1_0==0){cursor=0;}} }}P3_1=1;if(P3_1==0){delay(10);if(P3_1==0) //如果按键被按下{Kdelay();if(P3_1==0) //确定按键按下{if(cursor==1){sec++;//如果cursor=1则按键按下秒数加一if(sec==60)sec=0;//如果秒数等于60秒则回到0开始}if(cursor==2){min++;//如果cursor=2则按键按下分数加一if(min==60)min=0; 如果分数等于60分则回到0开始}if(cursor==3){hour++;//如果cursor=3则按键按下时数加一if(hour==24)hour=0; //如果时数等于24时则回到0开始}if(cursor==4){day++;//如果cursor=4则按键按下天数加一if(day==31)day=0; //如果天数等于31天则回到0开始}if(cursor==5){month++;//如果cursor=5则按键按下月数加一if(month==13)month=0; //如果月数等于13月则回到0开始}if(cursor==6){yearl++;//如果cursor=6则按键按下年数低位加一if(yearl==100)yearl=0; //如果年数等于100则回到0开始}if(cursor==7){yearh++;//如果cursor=7则按键按下年数高位加一if(yearh==30)yearh=20; //如果年数大于30则回到0开始}if(cursor==8){week++;//如果cursor=8则按键按下星期数加一if(week==8)week=1; //如果星期数等于8则回到0开始}}while(P3_1==0);}}P3_2=1; //写入时先写1if(P3_2==0){//按键按下delay(10);//延时10个毫秒if(P3_2==0)//确定按键按下{Kdelay();if(P3_2==0){if(cursor==1){sec--;//如果cursor=1则按键按下秒数减一if(sec==0)sec=59; //如果秒数小于0则回到59开始}if(cursor==2){min--;//如果cursor=2则按键按下分数减一if(min==0)min=59; //如果分数小于0则回到59开始}if(cursor==3){hour--;//如果cursor=3则按键按下时数减一if(hour==0)hour=23; //如果时数小于0则回到23开始}if(cursor==4){day--;//如果cursor=4则按键按下天数减一if(day==0)day=31; //如果天数小于0则回到31开始}if(cursor==5){month--;//如果cursor=5则按键按下月数减一if(month==0)month=12; //如果月数小于0则回到12开始}if(cursor==6){yearl--;//如果cursor=6则按键按下年的低位数减一if(yearl==0)yearl=99; //如果年数小于0则回到99开始}if(cursor==7){yearh--;//如果cursor=7则按键按下年的高位数减一if(yearh==20)yearh=30; //如果年数小于0则回到30开始}if(cursor==8){week--;//如果cursor=8则按键按下秒星期减一if(week==0)week=7; //如果星期数小于0则回到7开始}while(P3_2==0);}}}i=ReadTemperature();所连线路和单片机接口仿真图如图3所示:图3 仿真按键4)温度采集部分:DS18B20温度传感器,测温范围-55℃~+125℃,固有测温分辨率0.5℃。
一个成功的万年历汇编程序,显示日期时间和温度
ORG OOOOHUMP MAINORG OOIBHUMPSUBTlORG 0030HMAIN: MOV 5OH・#1H//显示缓冲区MOV51H.#2HMOV 52H・#3HMOV 53H・#4H〃显示缓冲区MOV 54H・#5H//显示缓冲区MOV 55H・#6HMOV 56H・#7HMOV 57H・#8H〃显示缓冲区MOV 58H・#0H//S4MOV 59H・#OH//S1MOV 5AH.#OH//0表示0〜9键按下,1〜6表示A〜F键按下,用于按键散转MOV5BH・#0H//0〜F键值,OFOH表示无键按下MOV 5CH・#21H//秒MOV 5DH・#43H//分MOV 5EH・#65H//时MOV 5FH・#41H//日MOV 60H・#02H//月MOV 61H・#0H 〃年MOV 62H・#22H//温度MOV 63H・#22H//温度SETB PSW・ 1MOVTLh#OFDHMOVTHh#OFFH MOV TMOD・#OOHMOV TCON・#04HMOV IR#08HMOV IE#88HSETB TRIMJMP: JNBPSW.l.MJMPlLCALL LED4RDELAYSJMP MJMP2MJMPl: LCALL LED8DELAYMJMP2; LCALL KEYLCALL KEYPRESJMP MJMPKEYPRE: MOV5BH.ACJNE A・#OFOH・KEYPRE1SJMP KEYPRE2VMSd HID mna AOiAU s Tiv:n:aN3io(ndNiswwoanvoiQNHlOOld ZfHSeVAOWaN3l001d'HVO#'V3Nf3脇is//Ha£'VAOW-droond03HdA3N dWnHa 丁i【og AOUIMoe'Mie Aoui q?「i【££ AOUIZfHOHorv aans□ moHae'VAOW:t3HdA3NOHHdAHN dwnd£OOHd dWn^fOOHddcOOHd dWnTOOHddIOOHd d 内mOOHdd£(X门d dW门:£0(门ddzooid dw 门:乙o(nddtoond dwnaoondtHHdAaN dwnaavid13H :03ydA3NHXda+v ® dpvfIH'VAOPVHdQ'v aavav Aow V'IH AOWavinw£#'9 AOWHVS'V AOI\I aviarnida AOW :记筑d 入HNV'HVe AOWV3NI乙3爼d入my Ofoirvaansor V aav0#'HVe AOW :I3HdA3N PL002P://MOV DPTR・#L002 //LCALL MOVXSBUFMOVA.5BHCJNE A・#OBH・PLOO2ENDMOV A.59HJZ PLOO2ENDMOVA.58HCJNEA・#O1H PLOO2P2MOVA.#5BHADD A.59HMOV R0.AINC @R0P LOO2P2:CJNE A・#O2H・PLOO2P3MOV A・#5EHADD A.59HMOV R0.AINC @R0PLOO2P3:CJNE A・#O3H・PLOO2ENDPL002END:LCALL S1MOVBUFCLR PSW.lUMP KEYPREOPL003P:MOV DPTR・#LOO3LCALL MOVXSBUFLCALL ADC0809SETB PSW.lUMP KEYPREOPH001P;//MOV DPTR.#H001//LCALL MOVXSBUFMOV A.5BHCLRCSUBB A・#0F0HJZ PHOOIENDLCALL COMMS4KPH001END:LCALLYDMOVBUFCLR PSW.lUMP KEYPREOPHOO2P; MOV DPTR.#H002LCALL MOVXSBUFMOVDPTR・#PWM14//E键设定:占空比1: 4LCALL MOVXPMWBUFUMP KEYPREOPH003P;MOV DPTR・#HOO3LCALL MO VXSBUFLCALL GET TEMPSETB PSW.lUMP KEYPREOSUBT1:PUSH ACC//PUSH PSWMOVTLb#OfdHMOVTHb#OFFHCPLP1.3//产生泄时脉冲LP4; POP PSWPOP ACCRETILED: MOV PO.#OFFHMOV PMR2LCALL DELAYMOVA・@RO MOV R LALED1:MOVA・R1MOV DPTR・#TABLEMOVCA,@A+DPTRMOV P0・AMOV PMR2LCALL DELAYRETLED2DELAY: mov R0.#4fhmov R2・#80h mov R3・#O2HLED2DELAYl:movA・R2RLA mov R2.AINC ROLCALL LEDDJNZ R3XED2DELAY1RETLED4LDELAY: MOV PO.#OOHMOV P3・#OFFHMOV R0.#4FH MOV R2・#OF7H MOV R3.#O4HLED4LDELAY1 ;MOV A.R2RLA MOV R2.AINC ROLCALLLEDDJNZ RMLED4LDELAY1 RETLED4RDELAY: MOV PO ・#OOHMOV P3・#OFFH MOV R0.#4FH MOV R2・#O7FH MOV R3.#O4HLED4RDELAY1 ;MOV A.R2RLA MOV R2.A INC RO LCALLLEDDJNZ R3.LED4RDELAY1 RETLED8DELAY; MOV PO ・#OOHMOV P3.#0FFHmov R2・#7fh mov R3・#O8HLED8DELAYl:movA ・R2RLA mov R2.A INC RO LCALLLEDDJNZ R3XED8DELAY1 RETDELAY:MOV R5・#O1H DJNZ R5.D0 RETLCALL KSJNZKl LCALL DELAY MOV A ・#OFOH UMP K5DO: DI: MOV R6.#O1AH DJNZ R6.D1KEY: MOV P3・#OFFHKI: LCALL DELAYLCALL KSJNZ K2MOV A・#0F0HUMP K5K2; MOV R2・#O7FHMOV R4.#00HK3: MOV A.R2MOV PO.ALCALL DELAYMOV A・P0ANLA・#0FHJBACC・O・L1 MOV A・#OOHUMPLKLI: JB ACC.l丄2MOVA,#01HUMPLKL2: JB ACC.2丄3MOV A・#02HUMPLKL3: JB ACC3.NEXTMOV A・#03HLK: ADD A・R4PUSH ACCK4; LCALL DELAYLCALL KSJNZK4POP ACCK5; RETNEXT:MOVA・#4ADDA.R4MOV R4.AMOV A.R2JNB ACC4K5RRAMOV R2.AUMP K3KS: MOV A・#0FHMOV PO.AMOV A・P0CPLAANLA・#0FH//SWAP ARETADC0809;CLRPL0//LCALL DELAYSETB P1.O//START.ALELCALL DELAYCLRPLOSETBP 12ADC08P; movc・Pl・2JNcADCOSPSETBPLlMOV P2・#OFFHMOVA.P2MOV 62H.AANLA・#0FHMOV 50H.AMOV A.62HSWAP AANLA,#OFHMOV5IH.AADC08M: RETDS18SL:CLREA:使用ds 1820 一;^要禁止任何中断产生LCALL INTT :初始化 ds 1820MOVA・#33HLCALL WRITE ;送入读 ds 1820 的 ROM 命令LCALLREAD ;开始读出当前ds 1820序列号MOV 40H.ALCALLREADMOV41H.ALCALLREADMOV 42H.ALCALLREADMOV 43H.ALCALLREADMOV 44H.ALCALLREADMOV 45H.ALCALLREADMOV 46H.ALCALLREADMOV 47H.ASETB EARET INTT: CLR EAINTTO; CLRPLOMOV R2・#200INTT1:CLRP1・ODJNZ R2JNTT1 :总线复位电平保持400us SETBPLO:释放 ds 1820 总线 MOV R2・#30INTT4: DJNZ R2JNTT4 ;释放 ds 1820 总线保持 60usCLRC:淸存在信号 ORLCPLOJC INTTO :存在吗?不存在则重新来 MOV R6・#80INTT5; ORLCPLOJC INTT3 DJNZ R6JNTT5 SJMP INTTOINTT3; MOV R2・#240 INTT2; DJNZ R2.INTT2SETB EA RETWRITE: CLR EA;向ds 1820写操作命令子程序MOV R3.#8 :写入ds 1820的bit 数•一个字节8个bitSETB Pl ・0MOV R4・#8RRCA:把一个字节data(A)分成8个bit 环務给C CLR Pl.O ;开始写入ds 1820总线要处于复位(低)状态 DJNZ R4.WR2 :ds 1820 总线复位保持 16usMOV Pl AC ;写入一个 bitMOV R4・#20DJNZ R4.WR3 ;等待 40usDJNZ R3.WR1 :写入下一个 bitSETB Pl.O ;重新释放ds 1820总线 SETB EA RETCLR EAMOV R6・#8 ;连续读8个bit CLR Pl.O :读前总线保持为低MOV R4・#4NOPSETB Pl.O ;开始读总线释放DJNZ R4RE2 :持续 8usMOVC.P1.0:从 dsl82O 总线读得一个 bitRRCA:把读得的位值环移给A MOV R5・#3ODJNZ R5RE3 ;持续 60usWRl: WR2: WR3: READ: REl; RE2: RE3:DJNZR6.RE1 ;读下一个 bitSETS Pl・0 ;重新释放ds 1820总线SETB EARET//温度转换和读取GET-TEMP: CLR EA :使用ds 1820 一;^要禁止任何中断产生LCALLINTT ;调用初使化子程序MOV A・#0CCHLCALL WRITE;送入跳过ROM 命令MOV A. #44HLCALL WRITE ;送入温度转换命令LCALL INTT :温度转换完全,再次初使化ds 1820MOV A・#0CCHLCALL WRITE;送入跳过ROM 命令MOVA・#OBEHLCALL WRITE ;送入读温度暂存器命令LCALLREADMOV 62H-A:读出温度值低字节存入R7LCALLREADMOV63H.A;读出谩度值高字节存入R6SETB EAGET TEMP1:RETMOVXSBUEMOV R7,#3MOV A.R7Move A.@A+DPTRMOV 50H.ADECR7MOV A.R7Move A・@ A+DPTRMOV51H.ADECR7MOV A.R7Move A・@ A+DPTRMOV 52H.ADECR7MOV A.R7Move A・@A+DPTRMOV 53H.ARETMOVXPMWBUEMOV R7.#iMOV A.R7MOVCA@A+DPTRMOV 58H・ADEC R7MOV A.R7MOVCA,@A+DPTRMOV 57H・ARETCOMMS4K; INC 58HMOVA.58HCJNE A・#04H・COMMS4K1MOV 58H・#O1HCOMMS4K1; RETYDMOVBUF: MOV A.58HCJNEA・#01H・YDMOVBUF2MOV R0・#5CHMOVA@ROANLA・#OFHMOV 50H・AMOV A. @ ROANLA.#OFOH SWA PAMOV51HAMOV 52H・#13HINC ROMOVA.@ROANLA・#0FHMOV 53H・A MOVA@RO ANLA・#0R)HSWAP AMOV 54H・AMOV 55H・#13HINC ROMOVA.@ROANLA・#0FHMOV 56H・AMOV A. @ ROANLA.#OFOHSWAP AMOV 57H・ASJMPYDMOVBUF4YDMOVBUF2; CJNE A・#02H・YDMOVBUF3MOV R0・#5FHMOVA@ROANLA.#OFHMOV 50H.A MOVA・@ROANLA.#OFOHSWAP AMOV 51 KAMOV 52H・#13HINC ROMOV A. @ ROANLA・#0FHMOV 53H・AMOVA.@ROANLA.#OFOHSWA PAMOV 54H,AMOV 55H・#13HINC ROMOVA,@ROANLA・#OFHMOV 56H.AMOVA.@ROANLA.#OFOHSWAP AMOV 57H.ASJMPYDMOVBUF4 YDMOVBUF3; MOV R0・#62HMOV A. @ ROANLA.#0FHMOV 50H・AMOVA@ROANLA.#OFOHSWAP AMOV 51 KAINC ROMOVA.@ROANLA・#OFHMOV 52H・AMOVA.@ROANLA.#OFOHSWAP AMOV 53H・AMOV 54H・#14HMOV 55H・#14HMOV 56H・#14HMOV 57H・#14H YDMOVBUF4; RETCOMMS IK: INC 59HMOV A.59HCJNE A・#05H・COMMS IKlMOV 59H・#01HCOMMS 1 KI; RETSIMOVBUF: MOV 5OH・#13HMOV51K#13HMOV 52H・#13HMOV 53H・#13HMOV 54H・#13HMOV 55H・#13HMOV 56H・#13HMOV 57H・#13HMOV A.59HCJNEA・#01H・S1MOVBUF2MOVA.58HCJNEA.#01H51MOV11MOV R0・#5CHSJMPS1MOV12SlMOVll; MOV R0,#5FHS1MOV12: MOVA.@ROANLA.#OFHMOV 50H・AMOV A. @ ROANLA.#OFOHSWAP AMOV51H.ASJMPS1M0VBUF4S1M0VBUF2: CJNE A・#02H・S1MOVBUF3MOVA.58HCJNEA.#01H51MOV21MOV R0・#5CHSJMPS1MOV22S1MOV21: MOV RO.#5FHS1MOV22: INC ROMOVA.@ROANLA・#OFHMOV 53H・AMOVA・@ROANLA.#OFOH SWA PAMOV 54H・ASJMPS1MOVBUF4S1MOVBUF3: CJNE A・#O3H・SIMOVBUFOMOVA.58H CJNEA ・#01H ・S1MOV31 MOV R0・#5CH SJMP S1MOV32 S1MOV31:MOV RO.#5FH S1MOV32: INC RO INC RO MOV A. @ RO ANLA ・#OFH MOV 56H.A MOV A. @ RO ANLA.#OFOH SWAP A MOV 57H,ASJMPS1MOVBUF4 SIMOVBUFO: CJNE A,#04H,S 1 MOVBUF4LCALLYDMOVBUFS1MOVBUF4: RETTABLE:DB OCOH ・OF9H ・OA4H ・OB0H ・99H ・92H,82H ・OF8H ・8OH ・90H ・88H ・83H ・OC6H ・OAlH ・86H ・8EH ・OCH ・89H.OC7H.OBFH.OFFH LOOl: L002; L003: DB 12H ・OH ・OH ・01HDB 12H.OOH.OOH.O2H DB 0AH.0DH.00H.03H HOOl; HOO2; HOO3; DB HH.OOH.OOH.OiH DB 11H.00H.00H.02H DB HH.00H.00H.03H p wml6:db O2h ・OCh p wnil4:db O2h ・O8hpwm21:db 06h.03hEND。
基于单片机带温度显示的电子万年历设计毕业设计 精品
毕业设计基于单片机带温度显示的电子万年历设计单片机应用技术飞速发展,纵观我们现在生活的各个领域,从导弹的导航装置,到飞机上各种仪表的控制,从计算机的网络通讯与数据传输,到工业自动化过程的实时控制和数据处理,以及我们生活中广泛使用的各种智能IC 卡、电子宠物等,这些都离不开单片机。
单片机是集CPU ,RAM ,ROM ,定时,计数和多种接口于一体的微控制器。
它体积小,成本低,功能强,广泛应用于智能产业和工业自动化上。
本设计着重要描述的就是基于AT89S52的单片机的电子万年历。
本文首先描述系统硬件工作原理,随后说明了本系统所应用的各硬件接口技术(既芯片驱动程序)和各个接口模块的功能及工作过程。
本设计的主导思想是软硬件相结合来进行各功能模块的编写。
电子万年历以硬件C语言为主体进行软件设计,增加了程序的可读性和可移植性。
系统通过LCD液晶输出显示数据,可以显示当前时间、公农历日期、星期、温度,并附有以峰鸣器为提示的闹铃功能。
关键词:单片机电子万年历公农历接口模块C语言MCU rapid development of applied technology, we now live Looking at the various fields, from the missile's navigation devices, to the various instruments on the aircraft control, computer network communications and data transmission, industrial automation to the process of real-time control and data Processing, and we live in the extensive use of the smart IC cards, electronic pets, these are inseparable from the SCM. SCM is set CPU, RAM, ROM, timing, counting on one interface and a variety of microcontrollers.Its small size, low cost, feature strong, smart widely used in industry and industrial automation.This design is going to describing the calendar based on AT89S52. System hardware of main body is described first, Follow the function, principle of work and hardware interface (that means the chip‟s drives) are introduced. The design…s main ideas is that composes soft and hardware to achieve the design.The calendar is designed with hardware C language as the Realization tool, which increased procedure readability and transplanting. The system shows the output by LCD1602, which can demonstrate the current time, the lunar calendar date, the week, the temperature and the system, can alter people with a small sounder.Keywords: MCU Electronic calendar Lunar calendar Interface module C Language.摘要............................................................................................................................................ I I ABSTRACT .. (III)目录 (IV)引言 (1)1 系统方案设计 (2)1.1单片机芯片的选择方案 (2)1.2显示模块选择方案 (3)1.3时钟芯片的选择方案 (3)1.4温度传感器的选择方案 (4)1.5电路设计最终方案 (4)2 系统设计说明 (5)2.1硬件模块图 (5)2.2系统原理 (5)2.3系统的软件流程图 (6)3 系统单元模块设计 (7)3.1主控模块(AT89S52模块) (7)3.2DS1302时钟模块 (9)3.2.1DS1302简介 (9)3.2.2DS1302结构与工作原理 (10)3.2.3控制命令字节与寄存器 (11)3.2.4DS1302电路设计图 (16)3.3公历与农历、星期转换模块 (16)3.3.1概述 (16)3.3.2基本原理 (17)3.3.3程序流程图 (18)3.4DS18B20温度模块 (20)3.4.1概述 (20)3.4.2DS18B20的工作原理 (20)3.4.3DS18B20与单片机的接口设计 (25)3.4.4DS18B20程序设计方案 (26)3.5整点报时模块 (29)3.5.1概述 (29)3.5.2设计原理 (29)3.5.3整点报时电路设计图 (29)3.6时间可调模块 (30)3.6.1键盘扫描原理 (30)3.6.2按键说明 (30)3.6.3软件设计思路 (31)3.7LCD1602显示模块 (31)3.7.1概述 (31)3.7.2结构与工作原理 (31)3.7.3LCD1602电路设计图 (34)3.8电源部分 (35)结束语 (36)参考文献 (37)致谢 (38)附录........................................................................................................................................ - 1 -引言近年来,随着我国科技的不断发展,我国经济发展的支柱产业——电子产业获得长足发展,近年来各种电子产品琳琅满目,随处可见,随着电子产品的更新速度的加快,各种功能强大,款式新颖的电子产品不断问世。
万年历显示年月日温度可以调时
sbit LcdEn =P2^7;
sfr DBPort =0x80;//P0=0x80,P1=0x90,P2=0xA0,P3=0xb0数据端口
//内部等待函数*******************************************************************
ReadValue=Read1302(DS1302_HOUR);
Time->Hour=((ReadValue&0x70)>>4) *10+(ReadValue&0x0F);
ReadValue=Read1302(DS1302_DAY);
Time->Day=((ReadValue&0x70)>>4) *10+(ReadValue&0x0F);
sbit SDA=P1^4;
sbit SPK=P1^2;
sbit DS1302_CLK=P1^7;
sbit DS1302_IO =P1^6;
sbit DS130C^0;
sbit ACC7=ACC^7;
char hide_sec,hide_min,hide_hour,hide_day,hide_week,hide_month,hide_year;
ReadValue=Read1302(DS1302_SECOND);
Time->Second=((ReadValue&0x70)>>4) *10+(ReadValue&0x0F);
ReadValue=Read1302(DS1302_MINUTE);
Time->Minute=((ReadValue&0x70)>>4) *10+(ReadValue&0x0F);
可以显示温度的万年历程序(已在PD1000开发板上运行)
//*********** DS1302 时间显示定义部分
sbit T_IO =P3^4;
sbit T_RST=P3^5;
sbit T_CLK=P3^6;
sbit ACC0=ACC^0;
sbit ACC7=ACC^7;
void Set(uchar,uchar); //根据选择调整相应项目
// (4):青岛普爱特版权所有,只供学习参考,不得应用于商业用途.
// (5):公司网站: 淘宝网店:
#include <reg51.h>
#include <string.h>
#include<intrins.h>
if(set==0){id++;if(id>7) id=0;}
while(set==0);
}
switch(id)
{
case 0:
sec=0;
Disp_line1(); Disp_line2();
while(1)
{
Disp_mod0(); //温度时间显示界面
}
}
//显示时间界面
void Disp_mod0(void)
{
if(lmcinit_or_not==1)
{LCMInit();
lmcinit_or_not=0;
}
}
//根据选择调整相应项目并写入DS1302
void Set(uchar sel,uchar sel_1)
{
signed char address,item;
signed char max,mini;
带温度显示的万年历--单片机课程设计
课程设计说明书课程名称:《单片机技术》设计题目:万年历院(部):电子信息与电气工程学院学生姓名:*******学号:************专业班级:************指导教师:*******20**年5月23日课程设计任务书万年历摘要:设计了一个带温度显示的万年历电路系统,该电路具有年、月、日、星期、时、分、秒、闹钟显示和调整功能,并且还能显示温度和按键鸣叫、整点鸣叫、定时闹钟鸣叫等功能。
其中显示部分采用LCD1602显示,时钟部分采用DS1302时钟芯片,温度部分采用DS18B20单线温度传感器。
报时鸣叫采用有源蜂鸣器并用三极管驱动。
软件方面我们采用C语言编程,利用Keil uVision4软件编写C语言程序并且生成HEX文件。
先将程序在Proteus仿真,通过之后再烧录到单片机中。
该设计的优点是充分利用了LCD1602的显示功能完成了万年历应该具有的功能并且还扩展了温度和闹钟。
不足之处是收到LCD1602显示功能的限制没能显示农历日期,而且报时部分只是发出滴滴声而不是语音报时。
关键词:万年历;LCD1602;温度传感器(DS18B20);时钟芯片(DS1302)目录1.设计背景 (1)1.1时钟的用途及精度的需求 (1)1.2万年历的使用现状及设计目的 (1)2.设计方案 (1)2.1任务分析 (1)2.2方案选择和论证 (2)2.2.1显示模块选择方案和论 (2)2.2.2时钟模块的方案选择和论证 (2)2.2.3按键控制模块的方案选择和论证 (2)2.2.4温度采集模块方案选择 (3)2.2.5方案的整体框图 (3)2.2.6设计流程图程序部分的拟定案 (4)3.方案实施 (5)3.1.1整体电路及其分析 (5)3.1.2电源电路 (6)3.1.3单片机最小系统 (6)3.1.4蜂鸣器及驱动电路 (7)3.1.5时钟芯片DS1302电路 (7)3.1.6温度采集芯片DS18B20电路 (8)3.1.7键盘控制电路 (8)3.1.8 LCD1602控制电路 (9)3.2软件仿真 (10)3.2.1 Proteus仿真软件介绍 (10)3.2.2电路仿真调试 (11)3.3 电路的焊接与调试 (12)4.结果与结论 (14)5.收获与致谢 (14)6.参考文献 (15)7.附件 (15)7.1电路原理图 (15)7.2 Proteus仿真图 (16)7.3电路工作中实物图 (17)7.4元器件清单 (19)7.5源程序清单 (20)1.设计背景1.1时钟的用途及精度的需求时间,对人们来说是非常宝贵的,准确的掌握时间和分配时间对人们来说至关重要。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
//秒 //分钟 //小时 //日 //月 //年 //星期
item=R1302(address+1)/16*10+R1302(address+1)%16; if (sel_1==0) item++; else item--; if(item>max) item=mini; if(item<mini) item=max;
void main(void)
{
Delay400Ms(); //启动等待,等 LCM 讲入工作状态
LCMInit();
//LCM 初始化
Delay5Ms();
//延时片刻(可不要)
mychar();
TMOD=0x01;
TH0=(65535-50000)/256;
TL0=(65535-50000)%256;
//冒号闪烁 if(flag==0)
{DisplayOneChar(3,0,0x3a); DisplayOneChar(6,0,0x3a);} else
{DisplayOneChar(3,0,0x20); DisplayOneChar(6,0,0x20);}
if(sec==1) //秒闪烁标志位 { if(flag==1) { DisplayOneChar(7,0,R1302(0x81)/16+0x30); //显示秒 DisplayOneChar(8,0,R1302(0x81)%16+0x30); } else {
Disp_line1(); Disp_line2();
id_case1_key();
break;
case 2://月
year=0;mon=1;
Disp_line1(); Disp_line2();
id_case1_key();
break;
case 3://日
mon=0;day=1;
Disp_line1(); Disp_line2();
// 版 本:PD1000 开发板
// 作 者:青岛普爱特
// 日 期:2011.02.28
//注:(1):主芯片 STC89C52RD 使用 12M 晶振
// (2):Keil uV3 3.30 编译运行通过
// (3):本例程在 PD1000 开发板平台上成功运行通过
// (4):青岛普爱特版权所有,只供学习参考,不得应用于商业用途.
{ Delay5Ms(); if(up==0) Set(id,0); if(id!=7) while(up==0);
} if (down==0) //减少
{ Delay5Ms(); if(down==0) Set(id,1); if(id!=7) while(down==0);
} }
//根据选择调整相应项目并写入 DS1302 void Set(uchar sel,uchar sel_1) {
if(min==1) //分钟闪烁标志位
{
if(flag==1)
{
DisplayOneChar(4,0,R1302(0x83)/16+0x30); //显示分钟
DisplayOneChar(5,0,R1302(0x83)%16+0x30);
}
else
{
DisplayOneChar(4,0,0x20);
//中断入口,冒号闪烁 void t0(void) interrupt 1 using 0 {
TH0=(65535-50000)/256; //50ms 定时 TL0=(65535-50000)%256; timecount++; if(timecount>9) {
timecount=0; flag=~flag; } } //id 为 1 时的下一级选择 void id_case1_key() { if (up==0) //增加
typedef unsigned int word;
Read_Temperature(char,char);
void mychar(void);
byte ow_reset(void);
byte read_byte(void);
void write_byte(char val);
void adjust_res(char res); //res 分别等于 0x1f, 0x3f, 0x5f 温度读数分辨率分别对应
break; case 6://分钟
hour=0;min=1; Disp_line1(); Disp_line2(); id_case1_key(); break; case 7://秒 min=0;sec=1; Disp_line1(); Disp_line2(); id_case1_key(); break; } }
//
0.5, 0.25, 0.125
//******* 1602LCD 驱动 ********************************************************** void WriteDataLCM(unsigned char WDLCM); void WriteCommandLCM(unsigned char WCLCM,BuysC); unsigned char ReadStatusLCM(void); void LCMInit(void); void DisplayOneChar(unsigned char X, unsigned char Y, unsigned char DData); void DisplayListChar(unsigned char X, unsigned char Y, unsigned char code *DData); void Delay5Ms(void); void Delay400Ms(void); unsigned char code week[]={"Week."};
DisplayOneChar(7,0,0x20);
//显示秒
DisplayOneChar(8,0,0x20);
}
}
else
{
DisplayOneChar(7,0,R1302(0x81)/16+0x30); //显示秒
DisplayOneChar(8,0,R1302(0x81)%16+0x30);
}
signed char address,item; signed char max,mini; if(sel==7) {address=0x80; max=0;mini=0;} if(sel==6) {address=0x82; max=59;mini=0;} if(sel==5) {address=0x84; max=23;mini=0;} if(sel==3) {address=0x86; max=31;mini=1;} if(sel==2) {address=0x88; max=12;mini=1;} if(sel==1) {address=0x8c; max=99;mini=0;} if(sel==4) {address=0x8a; max=7; mini=1;}
bit lmcinit_or_not;
//是否需要清屏标志位“1”为需要“0”为不需要
bit flag,sflag;
//flag 是时钟冒号闪烁标志,sflag 是温度负号显示标志
void Disp_line1(void); //显示屏幕第一行
void Disp_line2(void); //显示屏幕第二行
unsigned char inittime[7]={0x59,0x11,0x08,0x28,0x02,0x11,0x01};
//
秒 分钟 小时 日 月 年 星期
//***** 18B20 温度显示定义部
sbit DQ=P3^7;
//18B20 接 P3.7 口
typedef unsigned char byte;
void Set(uchar,uchar);
//根据选择调整相应项目
void RTInputByte(uchar);
/* 输入 1Byte */
uchar RTOutputByte(void);
/* 输出 1Byte */
void W1302(uchar, uchar);
// 向 DS1302 写入一个字节
id_case1_key();
break;
case 4://星期
day=0;weekk=1;
Disp_line1(); Disp_line2();
id_case1_key();
break;
case 5://小时
weekk=0;hour=1;
Disp_line1(); Disp_line2();
id_case1_key();
// (5):公司网站: 淘宝网店:
#include <reg51.h> #include <string.h> #include<intrins.h> #define uchar unsigned char
//功能引脚定义 sbit set= P1^0; //设置调整按键 sbit up = P1^1; //加 键 sbit down =P1^2; //减 键
//1602+18b20+ds1302 程序
// 程序名称:1602+18b20+ds1302 程序
// 实验目的:综合应用 lcd1602,ds18b20,ds1302
// 连接方法:将 LCD1602 液晶屏 插到 J9 端子上 引脚朝下
//
JP8 与 JP5 用 8p 排线连接
// 描 //
述:液晶显示当前时间(可调整) ,温度(精度可调) K1 设置键 K2 递增键 K3 递减键