基于51单片机的数字钟
单片机源程序如下:
- #include <reg52.h>
- #include<intrins.h> //包含_nop_()函数定义的头文件
- #include<lcd1602.h> //显示屏显示头文件
- #include <ds1302.h> //实时时钟头文件
- #define uchar unsigned char
- #define uint unsigned int
- uchar a1,a2;
- void Delay_ms(uint ms)
- {
- uint t;
- while(ms--)
- {
- t=580;
- while(t--);
- }
- }
- void main()
- {
- LCD_Initial(); //LCD屏幕初始化
- Delay_ms(50);
- while(1)
- {
- cahngehuamian();
- if(modle==0) //实时时钟模式
- {
- a2=1;
- if(a1==1)
- LCD_Initial();
- a1=0;
- Read_DS1302(); //读取断电时的后台数据
- changeTime(); //调节时间
- if( stoptime==0)
- Write_DS1302(); //写入设置的时间
- }
- if(modle==1) //闹钟模式
- {
- a1=1;
- if(a2==1)
- LCD_Initial();
- a2=0;
- changeNTime();
- alarmprint();
- }
- if(s1&s2&s3&s4)
- ……………………
- …………限于本文篇幅 余下代码请从51黑下载附件…………
复制代码
所有资料51hei提供下载:
数字钟.rar
(100.48 KB, 下载次数: 197)
|