久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

標題: 基于51單片機的倒計時程序設計 [打印本頁]

作者: 小不點@小太陽    時間: 2019-7-3 10:43
標題: 基于51單片機的倒計時程序設計
基于51單片機  led 12864的顯示器  顯示當前時間 和 距離高考小白第一個項目  望大神指點  多多指教
  1. #include <reg51.h>
  2. #include "lcd12864.h"
  3. #include "string.h"
  4. #include "stdio.h"
  5. #include "uart.h"
  6. #include "main.h"
  7. #include "ds1302.h"
  8. unsigned int i = 0;
  9. //當前時間
  10. extern uint         now_year,now_month,now_date,now_hour,now_min,now_sec;
  11. //倒計時時間
  12. extern int        days;
  13. extern int        hours;
  14. extern int        mins;
  15. extern int        secs;
  16. uchar temp[10] = {0};
  17. //獲取個位數并轉換為字符類型
  18. uchar get_ge(uint c){
  19.         uchar ge = c%10;
  20.         ge = ge+48;
  21.         return ge;
  22. }
  23. //獲取百位數并轉換為字符類型
  24. uchar get_shi(uint c){
  25.         uchar ge = c%100/10;
  26.         ge = ge+48;
  27.         return ge;
  28. }
  29. //獲取十位數并轉換為字符類型
  30. uchar get_bai(uint c){
  31.         uchar ge = c%1000/100;
  32.         ge = ge+48;
  33.         return ge;
  34. }


  35. void to_str(uint c,uchar* content,uint length){
  36.         
  37.         if(length == 1){
  38.                 *content = ' ';
  39.                 *(content+1) = get_ge(c);
  40.                 *(content+2) = '\0';
  41.         }
  42.         else if(length == 2){
  43.                 *(content) = get_shi(c);
  44.                 *(content+1) = get_ge(c);
  45.                 *(content+2) = '\0';
  46.         }
  47.         else if(length == 3){
  48.                 *content = ' ';
  49.                 *(content+1) = get_bai(c);
  50.                 *(content+2) = get_shi(c);
  51.                 *(content+3) = get_ge(c);
  52.                 *(content+4) = '\0';
  53.         }
  54. }
  55. void add_str(char* p){
  56.         while(*p !='\0')
  57.         {
  58.                 LCD12864_WriteData(*p);
  59.                 p++;        
  60.         }
  61. }
  62. //刷新顯示界面
  63. void refresh(){
  64.         //LCD12864_ClearScreen();//清屏有BUG
  65.         LCD12864_SetWindow(0, 0);
  66.         add_str("當前時間");
  67.         to_str(now_hour,temp,2);
  68.         add_str(temp);
  69.         add_str("時");
  70.         to_str(now_min,temp,2);
  71.         add_str(temp);
  72.         add_str("分");
  73.         LCD12864_SetWindow(1,0);
  74.         add_str("  距離高考還有  ");
  75.         LCD12864_SetWindow(2,0);
  76.         if(days < 10){
  77.                 to_str(days,temp,1);
  78.         }else if(days >= 10 && days < 100){
  79.                 to_str(days,temp,2);
  80.         }else{
  81.                 to_str(days,temp,3);
  82.         }
  83.         to_str(days,temp,3);
  84.         add_str(temp);
  85.         add_str("天");
  86.         LCD12864_SetWindow(2,3);
  87.         to_str(hours,temp,2);
  88.         add_str(temp);
  89.         add_str("時");
  90.         to_str(mins,temp,2);
  91.         add_str(temp);
  92.         add_str("分");
  93.         to_str(secs,temp,2);
  94.         add_str(temp);
  95.         LCD12864_SetWindow(3,0);
  96.          add_str("你還年輕你怕什么");
  97. //        if (days==127&& now_hour ==8&& now_min <=5){
  98. //                        TR0=0;
  99. //                LCD12864_SetWindow(0, 0);
  100. //                 add_str("擼起袖子加油干  ");
  101. //                LCD12864_SetWindow(1, 0);
  102. //                 add_str("                ");
  103. //                LCD12864_SetWindow(2, 0);
  104. //                add_str("                ");
  105. //                LCD12864_SetWindow(3, 0);
  106. //                 add_str("          謝顯山");
  107. //        }
  108. ////        if ( days ==138&&now_hour ==15 && now_min <=5){
  109. //                        TR0=0;
  110. //                LCD12864_SetWindow(0, 0);
  111. //                 add_str("人生最大的痛苦是");
  112. //                LCD12864_SetWindow(1, 0);
  113. //                 add_str("夢醒了無路可走  ");
  114. //                LCD12864_SetWindow(2, 0);
  115. //                add_str("  不怕萬人阻擋  ");
  116. //                LCD12864_SetWindow(3, 0);
  117. //                 add_str("  只怕自己投降  ");
  118. //        }
  119. //        
復制代碼

時間  和勵志標語  可在基礎上進行更改

TIM截圖20190703104122.png (102.52 KB, 下載次數: 16)

TIM截圖20190703104122.png

倒計時.7z

49.74 KB, 下載次數: 14, 下載積分: 黑幣 -5


作者: 七猴    時間: 2019-7-31 10:00
這里有用到定時器嗎?為什么會有TR0呢?
作者: zhong2463    時間: 2019-8-14 10:17
請問有電路圖參考一下呢嗎?




歡迎光臨 (http://www.zg4o1577.cn/bbs/) Powered by Discuz! X3.1
主站蜘蛛池模板: 久久精品亚洲欧美日韩久久 | 免费99视频 | 伊人精品一区二区三区 | 3p视频在线观看 | 91视频大全 | 欧美激情在线精品一区二区三区 | 91精品国产欧美一区二区 | 操操网站 | a在线观看| 久久免费高清 | 亚洲成人激情在线观看 | 日本中出视频 | 亚洲精品在线看 | 国产亚洲黄色片 | 国产精品成人69xxx免费视频 | 亚洲精品女优 | 国精品一区 | 国产成人综合亚洲欧美94在线 | 视频一区二区中文字幕日韩 | 特黄色毛片 | 特级毛片 | 成人免费在线视频 | 久久91精品久久久久久9鸭 | 国内精品久久精品 | 91免费视频观看 | www.天天操.com | 日本成人久久 | 精品国产免费一区二区三区五区 | 国产999精品久久久久久 | 日韩视频91 | 久久久精品综合 | 久久黄视频| 日本黄色高清视频 | 懂色av一区二区三区在线播放 | 成人精品视频在线观看 | 亚洲网站在线播放 | 欧美日韩精品影院 | 亚洲欧美精品 | 日韩欧美中文字幕在线视频 | 精品小视频 | av毛片 |