標(biāo)題: 51單片機(jī)DS1302與LCD1602程序 時鐘 [打印本頁]

作者: 白艾    時間: 2017-5-5 16:25
標(biāo)題: 51單片機(jī)DS1302與LCD1602程序 時鐘
DS1302與LCD1602程序  時鐘 51單片機(jī)

全部源碼下載:
程序.zip (42.29 KB, 下載次數(shù): 36)



  1. /*******************************************************************************
  2. *                 
  3. *                                        普中科技
  4. --------------------------------------------------------------------------------
  5. * 實(shí) 驗(yàn) 名                 : DS1302時鐘顯示試驗(yàn)
  6. * 實(shí)驗(yàn)說明       : LCD1602顯示時鐘信息
  7. * 連接方式       : 見連接圖
  8. * 注    意                 :
  9. *******************************************************************************/

  10. #include<reg51.h>
  11. #include"lcd.h"
  12. #include"ds1302.h"

  13. void LcdDisplay();

  14. /*******************************************************************************
  15. * 函數(shù)名         : main
  16. * 函數(shù)功能                   : 主函數(shù)
  17. * 輸入           : 無
  18. * 輸出                  : 無
  19. *******************************************************************************/

  20. void main()
  21. {
  22.         LcdInit();
  23.         Ds1302Init();
  24.         while(1)
  25.         {       
  26.                 Ds1302ReadTime();
  27.                 LcdDisplay();       
  28.         }
  29.        
  30. }
  31. /*******************************************************************************
  32. * 函數(shù)名         : LcdDisplay()
  33. * 函數(shù)功能                   : 顯示函數(shù)
  34. * 輸入           : 無
  35. * 輸出                  : 無
  36. *******************************************************************************/

  37. void LcdDisplay()
  38. {
  39.         LcdWriteCom(0x80+0X40);
  40.         LcdWriteData('0'+TIME[2]/16);                                //時
  41.         LcdWriteData('0'+(TIME[2]&0x0f));                                 
  42.         LcdWriteData('-');
  43.         LcdWriteData('0'+TIME[1]/16);                                //分
  44.         LcdWriteData('0'+(TIME[1]&0x0f));       
  45.         LcdWriteData('-');
  46.         LcdWriteData('0'+TIME[0]/16);                                //秒
  47.         LcdWriteData('0'+(TIME[0]&0x0f));

  48.         LcdWriteCom(0x80);
  49.         LcdWriteData('2');
  50.         LcdWriteData('0');
  51.         LcdWriteData('0'+TIME[6]/16);                        //年
  52.         LcdWriteData('0'+(TIME[6]&0x0f));
  53.         LcdWriteData('-');
  54.         LcdWriteData('0'+TIME[4]/16);                        //月
  55.         LcdWriteData('0'+(TIME[4]&0x0f));
  56.         LcdWriteData('-');
  57.         LcdWriteData('0'+TIME[3]/16);                        //日
  58.         LcdWriteData('0'+(TIME[3]&0x0f));
  59.         LcdWriteCom(0x8D);
  60.         LcdWriteData('0'+(TIME[5]&0x07));        //星期                         
  61. }
復(fù)制代碼



作者: 宮本無三四    時間: 2017-5-6 09:52
下來看看
作者: PK-V1    時間: 2017-9-16 18:20
拿普中開發(fā)板的程序來賣,是不是有點(diǎn)賤




歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1