包括LCD1602顯示和數(shù)碼管顯示
單片機源程序如下:
- /*******************************************************************************
- *
- * 普中科技
- --------------------------------------------------------------------------------
- * 實 驗 名 : DS1302時鐘顯示試驗
- * 實驗說明 : LCD1602顯示時鐘信息
- * 連接方式 : 見連接圖
- * 注 意 :
- *******************************************************************************/
- #include<reg51.h>
- #include"lcd.h"
- #include"ds1302.h"
- void LcdDisplay();
- /*******************************************************************************
- * 函數(shù)名 : main
- * 函數(shù)功能 : 主函數(shù)
- * 輸入 : 無
- * 輸出 : 無
- *******************************************************************************/
- void main()
- {
- LcdInit();
- Ds1302Init();
- while(1)
- {
- Ds1302ReadTime();
- LcdDisplay();
- }
-
- }
- /*******************************************************************************
- * 函數(shù)名 : LcdDisplay()
- * 函數(shù)功能 : 顯示函數(shù)
- * 輸入 : 無
- * 輸出 : 無
- *******************************************************************************/
- 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, 下載次數(shù): 6)
2018-12-12 10:10 上傳
點擊文件名下載附件
關于DS1302的實時時鐘程序 下載積分: 黑幣 -5
|