標題: arduino uno在窗口監(jiān)視器輸出電腦時間的編程思路? [打印本頁]

作者: yyf1233    時間: 2018-9-27 04:46
標題: arduino uno在窗口監(jiān)視器輸出電腦時間的編程思路?
本帖最后由 yyf1233 于 2018-9-27 17:13 編輯

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

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


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

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

串口監(jiān)視器

串口監(jiān)視器

作者: 小貓貓愛吃魚    時間: 2018-9-27 06:56
窗口監(jiān)視器,具體是指什么?
作者: cccc888    時間: 2018-9-27 09:33
外接時鐘芯片 DS3231.zip (378.7 KB, 下載次數(shù): 19)




作者: lidan652278089    時間: 2018-9-27 09:37
窗口監(jiān)視器是?
作者: yyf1233    時間: 2018-9-27 17:10
cccc888 發(fā)表于 2018-9-27 09:33
外接時鐘芯片

謝謝老哥!但是我們說不用rtc函數(shù)調(diào)用。。
作者: angmall    時間: 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ù)制代碼

作者: 小貓貓愛吃魚    時間: 2018-9-27 20:28
用 1602 來顯示,可以完成程序
作者: yyf1233    時間: 2018-9-28 22:32
angmall 發(fā)表于 2018-9-27 20:08
我給你來個程序試試

老哥太感謝你了!。
我是小白你能給我稍微講一下思路嗎?
感激不盡。!
作者: 昕媛    時間: 2018-9-29 09:56

用 1602 來顯示,可以完成程序




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