万年历的实物图:
电子万年历原理图如下:
仿真原理图如下
单片机源程序如下:
#include //#include"DS18B20_3.H" #include #include #define uint unsigned int #define uchar unsigned char #define wd 1 //定义是否有温度功能 =0时无温度,=1时有温度 #define yh 0x80 //LCD第一行的初始位置,因为LCD1602字符地址首位D7恒定为1(100000000=80) #define er 0x80+0x40 //LCD第二行初始位置(因为第二行第一个字符位置地址是0x40) //液晶屏的与C51之间的引脚连接定义(显示数据线接C51的P0口) sbit en=P2^7; sbit rw=P2^6; //如果硬件上rw接地,就不用写这句和后面的rw=0了 sbit rs=P2^5; //校时按键与C51的引脚连接定义 sbit set=P3^0; //设置键 sbit add=P3^1; //加键 sbit dec=P3^2; //减键 sbit seeNL_NZ=P3^3; //查看农历/闹钟 sbit DQ=P3^7; // sbit buzzer=P2^0; //蜂鸣器,通过三极管8550驱动,端口低电平响 sbit led=P2^4; //LCD背光开关 bit led1=1; bit ZDK=1,NZK=1; //整点报时,闹钟开关控制位 =0时,关闭,=1时,开启 bit zdkg=0,nzkg=0; unsigned char temp_miao; unsigned char bltime; //背光亮的时间 //DS1302时钟芯片与C51之间的引脚连接定义 sbit IO=P1^1; sbit SCLK=P1^0; sbit RST=P1^2; uchar a,miao,shi,fen,ri,yue,nian,week,setn,temp; uint flag; //flag用于读取头文件中的温度值,和显示温度值 bit c_moon; uchar nz_shi=12,nz_fen=0,nz_miao=0,setNZn; //定义闹钟变量 uchar shangyimiao,bsn,temp_hour; //记录上一秒时间 uchar T_NL_NZ; //计数器 bit timeron=0; //闹钟启用标志位 bit baoshi=0; //整点报时标志位 bit p_r=0; //平年/润年 =0表示平年,=1表示润年 data uchar year_moon,month_moon,day_moon,week; sbit ACC0=ACC^0; sbit ACC7=ACC^7; /************************************************************ ACC累加器=A ACC.0=E0H ACC.0就是ACC的第0位。Acc可以位寻址。 累加器ACC是一个8位的存储单元,是用来放数据的。但是,这个存储单元有其特殊的地位, 是单片机中一个非常关键的单元,很多运算都要通过ACC来进行。以后在学习指令时, 常用A来表示累加器。但有一些地方例外,比如在PUSH指令中,就必须用ACC这样的名字。 一般的说法,A代表了累加器中的内容、而ACC代表的是累加器的地址。 ***************************************************************/ //********阳历转换阴历表************************************ code uchar year_code[597]={ 0x04,0xAe,0x53, //1901 0 0x0A,0x57,0x48, //1902 3 0x55,0x26,0xBd, //1903 6 0x0d,0x26,0x50, //1904 9 0x0d,0x95,0x44, //1905 12 0x46,0xAA,0xB9, //1906 15 0x05,0x6A,0x4d, //1907 18 0x09,0xAd,0x42, //1908 21 0x24,0xAe,0xB6, //1909 0x04,0xAe,0x4A, //1910 0x6A,0x4d,0xBe, //1911 0x0A,0x4d,0x52, //1912 0x0d,0x25,0x46, //1913 0x5d,0x52,0xBA, //1914 0x0B,0x54,0x4e, //1915 0x0d,0x6A,0x43, //1916 0x29,0x6d,0x37, //1917 0x09,0x5B,0x4B, //1918 0x74,0x9B,0xC1, //1919 0x04,0x97,0x54, //1920 0x0A,0x4B,0x48, //1921 0x5B,0x25,0xBC, //1922 0x06,0xA5,0x50, //1923 0x06,0xd4,0x45, //1924 0x4A,0xdA,0xB8, //1925 0x02,0xB6,0x4d, //1926 0x09,0x57,0x42, //1927 0x24,0x97,0xB7, //1928 0x04,0x97,0x4A, //1929 0x66,0x4B,0x3e, //1930 0x0d,0x4A,0x51, //1931 0x0e,0xA5,0x46, //1932 0x56,0xd4,0xBA, //1933 0x05,0xAd,0x4e, //1934 0x02,0xB6,0x44, //1935 0x39,0x37,0x38, //1936 0x09,0x2e,0x4B, //1937 0x7C,0x96,0xBf, //1938 0x0C,0x95,0x53, //1939 0x0d,0x4A,0x48, //1940 0x6d,0xA5,0x3B, //1941 0x0B,0x55,0x4f, //1942 0x05,0x6A,0x45, //1943 0x4A,0xAd,0xB9, //1944 0x02,0x5d,0x4d, //1945 0x09,0x2d,0x42, //1946 0x2C,0x95,0xB6, //1947 0x0A,0x95,0x4A, //1948 0x7B,0x4A,0xBd, //1949 0x06,0xCA,0x51, //1950 0x0B,0x55,0x46, //1951 0x55,0x5A,0xBB, //1952 0x04,0xdA,0x4e, //1953 0x0A,0x5B,0x43, //1954 0x35,0x2B,0xB8, //1955 0x05,0x2B,0x4C, //1956 0x8A,0x95,0x3f, //1957 0x0e,0x95,0x52, //1958 0x06,0xAA,0x48, //1959 0x7A,0xd5,0x3C, //1960 0x0A,0xB5,0x4f, //1961 0x04,0xB6,0x45, //1962 0x4A,0x57,0x39, //1963 0x0A,0x57,0x4d, //1964 0x05,0x26,0x42, //1965 0x3e,0x93,0x35, //1966 0x0d,0x95,0x49, //1967
设计资源 培训 开发板 精华推荐
- LTC3630AEMSE 4V 至 63V 输入至 -12V 输出、正负转换器的典型应用电路
- LT4275CIMS IEEE 802.3af(类型 1)13W 受电设备的典型应用电路
- ADP1829、APD210X 和 ADP171X 参考设计
- LT1930、5V 至 12V/300mA 升压型 DC/DC 转换器
- 用于恒流吸收器的 NCP431B 可编程精密基准的典型应用
- LTC4068-4.2 的典型应用 - 具有可编程终端的独立线性锂离子电池充电器
- LT3990EMSE-3.3 5V 降压转换器的典型应用
- NCS36510GEVK:适用于 2.4 GHz IEEE 802.15.4-2006 应用评估套件的低功耗片上系统
- 用于仪表的 8/10/12 位、1 通道 DAC
- 【征集令】基于ESP8266的WIFI遥控船——永不沉没