Robofun 機器人論壇

標題: [Arduino問題] 請教有關 TimedAction 程式? [打印本頁]

作者: pizg    時間: 2012-12-1 16:01
標題: [Arduino問題] 請教有關 TimedAction 程式?
我的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. }
複製代碼

作者: vegewell    時間: 2012-12-1 20:00
回復 1# pizg

在 TimedAction.h 裡
  更改   #include "WProgram.h"
成為#include "Arduino.h"
作者: pizg    時間: 2012-12-2 18:13
回復  pizg

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



    感謝前輩指點.




歡迎光臨 Robofun 機器人論壇 (https://robofun.net/forum/) Powered by Discuz! X3.2