Robofun 機器人論壇

 找回密碼
 申請會員
搜索
熱搜: 活動 交友 discuz
查看: 4835|回復: 2
打印 上一主題 下一主題

[Arduino問題] 請教有關 TimedAction 程式?

[複製鏈接]
跳轉到指定樓層
1#
發表於 2012-12-1 16:01:49 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
我的Arduino IDE是1.0.2版,
Upload時會出現下列訊息, 請問各位前輩該如何解決?

Timer1:7: error: 'TimedAction' does not name a type
Timer1.ino: In function 'void loop()':
Timer1:18: error: 'serialAction' was not declared in this scope

  1. #include <MeetAndroid.h>
  2. #include <TimedAction.h>
  3. // declare MeetAndroid so that you can call functions with it
  4. MeetAndroid meetAndroid;

  5. long interval = 1000; // 間隔時間,單位為毫秒(miliseconds)
  6. TimedAction serialAction = TimedAction(interval, printHello);
  7. unsigned long now;

  8. void setup() {
  9. Serial.begin(57600);
  10. meetAndroid.registerFunction(exeA, 'a');
  11. }

  12. void loop()
  13. {
  14. meetAndroid.receive(); // you need to keep this in your loop() to receive events
  15. serialAction.check();
  16. }

  17. void exeA(byte flag, byte numOfValues)
  18. {
  19. int time[3];
  20. meetAndroid.getIntValues(time);
  21. now = time[0] * 3600 + time[1] * 60 + time[2];
  22. }

  23. void printHello()
  24. {
  25. now = now + 1;
  26. int h = now % 3600;
  27. int m = (now - h * 3600) % 60;
  28. int s = now - h * 3600 - m * 60;
  29. Serial.print(h); Serial.print(":");
  30. Serial.print(m); Serial.print(":");
  31. Serial.println(s);
  32. }
複製代碼
2#
發表於 2012-12-1 20:00:02 | 只看該作者
回復 1# pizg

在 TimedAction.h 裡
  更改   #include "WProgram.h"
成為#include "Arduino.h"
3#
 樓主| 發表於 2012-12-2 18:13:41 | 只看該作者
回復  pizg

在 TimedAction.h 裡
  更改   #include "WProgram.h"
成為#include "Arduino.h"
vegewell 發表於 2012-12-1 20:00



    感謝前輩指點.
您需要登錄後才可以回帖 登錄 | 申請會員

本版積分規則

小黑屋|手機版|Archiver|機器人論壇 from 2005.07

GMT+8, 2024-7-1 17:35 , Processed in 0.121240 second(s), 9 queries , Apc On.

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回復 返回頂部 返回列表