我要做的就是将 Arduino 编译为 Android 'hello world' 程序,来自“Beginning Android ADK with Arduino”一书。
这是代码
#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 不是答案。