找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索

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

查看數(shù): 6710 | 評論數(shù): 8 | 收藏 0
關(guān)燈 | 提示:支持鍵盤翻頁<-左 右->
    組圖打開中,請稍候......
發(fā)布時間: 2018-9-27 04:46

正文摘要:

本帖最后由 yyf1233 于 2018-9-27 17:13 編輯 老哥們好 :) 剛接觸arduino,我們要做一個簡單的項目,在arduino編程然后要求在串口監(jiān)視器輸出電腦時間 即打開窗口監(jiān)視器,然后得到輸出格式為 Heure de votr ...

回復(fù)

ID:403919 發(fā)表于 2018-9-29 09:56

用 1602 來顯示,可以完成程序
ID:402958 發(fā)表于 2018-9-28 22:32
angmall 發(fā)表于 2018-9-27 20:08
我給你來個程序試試

老哥太感謝你了!!!
我是小白你能給我稍微講一下思路嗎?
感激不盡。!
ID:303383 發(fā)表于 2018-9-27 20:28
提示: 作者被禁止或刪除 內(nèi)容自動屏蔽
ID:155507 發(fā)表于 2018-9-27 20:08
我給你來個程序試試




  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ù)制代碼
ID:402958 發(fā)表于 2018-9-27 17:10

謝謝老哥!但是我們說不用rtc函數(shù)調(diào)用。。
ID:402979 發(fā)表于 2018-9-27 09:37
窗口監(jiān)視器是?
ID:258566 發(fā)表于 2018-9-27 09:33
外接時鐘芯片 DS3231.zip (378.7 KB, 下載次數(shù): 19)



ID:303383 發(fā)表于 2018-9-27 06:56
提示: 作者被禁止或刪除 內(nèi)容自動屏蔽

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

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

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