【发布时间】:2012-08-23 15:23:10
【问题描述】:
我要做的只是将“使用 Arduino 开始 Android ADK”一书中的 Arduino 编译为 Android 的“hello world”程序。
这里是代码
#include <Max3421e.h>
#include <Usb.h>
#include <AndroidAccessory.h>
#define ARRAY_SIZE 12
AndroidAccessory acc("Manufacturer", "Model", "Description",
"Version", "URI", "Serial");
char hello[ARRAY_SIZE] = {'h','e','l','l','o',' ',
'w','o','r','l','d','!'};
void setup() {
Serial.begin(115200);
acc.powerOn();
}
void loop() {
if (acc.isConnected()) {
for(int x = 0; x < ARRAY_SIZE; x++) {
Serial.print(hello[x]);
delay(250);
}
Serial.println();
delay(250);
}
}
我的错误
C:\Users\efossum\arduino-1.0.1\libraries\UsbHost/AndroidAccessory.h: In function 'void setup()':
C:\Users\efossum\arduino-1.0.1\libraries\UsbHost/AndroidAccessory.h:68: error: 'void AndroidAccessory::powerOn()' is private
sketch_aug23a:14: error: within this context
我查看了 AndroidAccessory.h 并确定它是私有的,但我应该更改什么才能使其正常工作?我认为使函数 pulic 不是答案。
【问题讨论】:
-
嗨,埃里克。您是否设法编译代码?我尝试在 IDE v22 和 v1.0.2 上使用第 1 步中的库在 arduino 实验室网站 labs.arduino.cc/ADK/AccessoryMode 上进行编译。我在 Windows 8 和 ubuntu 12.10 上尝试过与您一样的错误。这真是令人沮丧