包括LCD1602显示和数码管显示
单片机源程序如下:
- /*******************************************************************************
- *
- * 普中科技
- --------------------------------------------------------------------------------
- * 实 验 名 : DS1302时钟显示试验
- * 实验说明 : LCD1602显示时钟信息
- * 连接方式 : 见连接图
- * 注 意 :
- *******************************************************************************/
- #include<reg51.h>
- #include"lcd.h"
- #include"ds1302.h"
- void LcdDisplay();
- /*******************************************************************************
- * 函数名 : main
- * 函数功能 : 主函数
- * 输入 : 无
- * 输出 : 无
- *******************************************************************************/
- void main()
- {
- LcdInit();
- Ds1302Init();
- while(1)
- {
- Ds1302ReadTime();
- LcdDisplay();
- }
-
- }
- /*******************************************************************************
- * 函数名 : LcdDisplay()
- * 函数功能 : 显示函数
- * 输入 : 无
- * 输出 : 无
- *******************************************************************************/
- void LcdDisplay()
- {
- LcdWriteCom(0x80+0X40);
- LcdWriteData('0'+TIME[2]/16); //时
- LcdWriteData('0'+(TIME[2]&0x0f));
- LcdWriteData('-');
- LcdWriteData('0'+TIME[1]/16); //分
- LcdWriteData('0'+(TIME[1]&0x0f));
- LcdWriteData('-');
- LcdWriteData('0'+TIME[0]/16); //秒
- LcdWriteData('0'+(TIME[0]&0x0f));
- LcdWriteCom(0x80);
- LcdWriteData('2');
- LcdWriteData('0');
- LcdWriteData('0'+TIME[6]/16); //年
- LcdWriteData('0'+(TIME[6]&0x0f));
- LcdWriteData('-');
- LcdWriteData('0'+TIME[4]/16); //月
- LcdWriteData('0'+(TIME[4]&0x0f));
- LcdWriteData('-');
- LcdWriteData('0'+TIME[3]/16); //日
- LcdWriteData('0'+(TIME[3]&0x0f));
- LcdWriteCom(0x8D);
- LcdWriteData('0'+(TIME[5]&0x07)); //星期
- }
复制代码
所有资料51hei提供下载:
14、实时时钟DS1302.rar
(358.34 KB, 下载次数: 6)
|