找回密碼
 立即注冊(cè)

QQ登錄

只需一步,快速開始

搜索
查看: 6709|回復(fù): 8
打印 上一主題 下一主題
收起左側(cè)

arduino uno在窗口監(jiān)視器輸出電腦時(shí)間的編程思路?

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
本帖最后由 yyf1233 于 2018-9-27 17:13 編輯

老哥們好 :)
剛接觸arduino,我們要做一個(gè)簡(jiǎn)單的項(xiàng)目,在arduino編程然后要求在串口監(jiān)視器輸出電腦時(shí)間
即打開窗口監(jiān)視器,然后得到輸出格式為
Heure de votre PC
18:20:30 (無小數(shù)點(diǎn)和其余符號(hào))

希望諸位大佬能指點(diǎn)一下如何編程
感激不盡~~~


PS 我們只用arduino uno 和 1602,要求不調(diào)用其他函數(shù)

捕獲.PNG (46.44 KB, 下載次數(shù): 38)

串口監(jiān)視器

串口監(jiān)視器
分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享淘帖 頂 踩
回復(fù)

使用道具 舉報(bào)

沙發(fā)
ID:303383 發(fā)表于 2018-9-27 06:56 | 只看該作者
提示: 作者被禁止或刪除 內(nèi)容自動(dòng)屏蔽
回復(fù)

使用道具 舉報(bào)

板凳
ID:258566 發(fā)表于 2018-9-27 09:33 | 只看該作者
外接時(shí)鐘芯片 DS3231.zip (378.7 KB, 下載次數(shù): 19)



回復(fù)

使用道具 舉報(bào)

地板
ID:402979 發(fā)表于 2018-9-27 09:37 | 只看該作者
窗口監(jiān)視器是?
回復(fù)

使用道具 舉報(bào)

5#
ID:402958 發(fā)表于 2018-9-27 17:10 | 只看該作者

謝謝老哥!但是我們說不用rtc函數(shù)調(diào)用。。
回復(fù)

使用道具 舉報(bào)

6#
ID:155507 發(fā)表于 2018-9-27 20:08 | 只看該作者
我給你來個(gè)程序試試




  1. unsigned long currentMicros;
  2. unsigned long previousMicros;
  3. unsigned long elapsedTime;

  4. byte hundredths;
  5. byte tenths;
  6. byte secondsOnes;
  7. byte oldSecondsOnes;
  8. byte secondsTens;
  9. byte minutesOnes = 6; // Replace this with the most current time
  10. byte minutesTens = 5;
  11. byte hoursOnes = 0;
  12. byte hoursTens = 1;

  13. void setup(){

  14.   Serial.begin(115200); // make serial monitor match
  15.   currentMicros = micros();
  16.   previousMicros = currentMicros;
  17.   Serial.println ("Setup Done");
  18. }

  19. void loop(){

  20.   currentMicros = micros();

  21.   // how long's it been?
  22.   elapsedTime = currentMicros - previousMicros;
  23.   //Serial.print ("Elapsed: ");  
  24.   //Serial.println (elapsedTime);
  25.   if ( elapsedTime >=10000UL){  // 0.01 second passed? Update the timers
  26.     elapsedTime = 0;
  27.     previousMicros  = previousMicros + 10000UL;
  28.     hundredths = hundredths+1;
  29.     if (hundredths == 10){
  30.       hundredths = 0;
  31.       tenths = tenths +1;
  32.       if (tenths == 10){
  33.         tenths = 0;
  34.         secondsOnes = secondsOnes + 1;
  35.         if (secondsOnes == 10){
  36.           secondsOnes = 0;
  37.           secondsTens = secondsTens +1;
  38.           if (secondsTens == 6){
  39.             secondsTens = 0;
  40.             minutesOnes =  minutesOnes + 1;
  41.             if (minutesOnes == 10){
  42.               minutesOnes = 0;
  43.               minutesTens = minutesTens +1;
  44.               if (minutesTens == 6){
  45.                 minutesTens = 0;
  46.                 hoursOnes = hoursOnes +1;
  47.                 if (hoursOnes == 10){
  48.                   hoursOnes = 0;
  49.                   hoursTens = hoursTens =1;
  50.                   if (hoursOnes == 4 && hoursTens ==2){
  51.                     hoursOnes = 0;
  52.                     hoursTens = 0;
  53.                   }
  54.                 }
  55.               } // minutesTens rollover check
  56.             } // minutesOnes rollover check
  57.           } // secondsTens rollover check
  58.         } // secondsOnes rollover check
  59.       } // tenths rollover check
  60.     } // hundredths rollover check
  61.   } // hundredths passing check



  62.   if (oldSecondsOnes != secondsOnes){  // show the elapsed time
  63.     oldSecondsOnes = secondsOnes;
  64.     Serial.print ("Time: ");
  65.     Serial.print (hoursTens);
  66.     Serial.print(hoursOnes);
  67.     Serial.print(":");
  68.     Serial.print(minutesTens);
  69.     Serial.print(minutesOnes);
  70.     Serial.print(":");
  71.     Serial.print(secondsTens);
  72.     Serial.println(secondsOnes);

  73. /*
  74. if ( hoursTens == 0 && hoursOnes == 6 ** minutesTens == 0 && minutesOnes == 0 && secondsTens == 0 && secondsOnes == 0){
  75. // alarm time!
  76. }
  77. */

  78.   } // end one second check
  79. } // end loop


復(fù)制代碼
回復(fù)

使用道具 舉報(bào)

7#
ID:303383 發(fā)表于 2018-9-27 20:28 | 只看該作者
提示: 作者被禁止或刪除 內(nèi)容自動(dòng)屏蔽
回復(fù)

使用道具 舉報(bào)

8#
ID:402958 發(fā)表于 2018-9-28 22:32 | 只看該作者
angmall 發(fā)表于 2018-9-27 20:08
我給你來個(gè)程序試試

老哥太感謝你了。!
我是小白你能給我稍微講一下思路嗎?
感激不盡!。
回復(fù)

使用道具 舉報(bào)

9#
ID:403919 發(fā)表于 2018-9-29 09:56 | 只看該作者

用 1602 來顯示,可以完成程序
回復(fù)

使用道具 舉報(bào)

本版積分規(guī)則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表