所以我一直在阅读这本书,现在我发现自己卡在第 49-50 页,试图在 Android 和我的 MEGA ADK 2560 R3 板之间建立第一个通信提示。我应该包括我已经下载了更新的 USB host shield 2.0 并将其重命名为 USB_HOST_20,这就是我所做的。
到目前为止,这是我的代码:
#include <max3421e.h>
#include <Usb.h>
#include <AndroidAccessory.h>
#define ARRAY_SIZE 12
AndroidAccessory acc("Google,Inc.","ExtendHelloWorld","Test","1.0","http://www.android.com");
char hello[ARRAY_SIZE] = {'h','e','l','l','o',' ','w','o','r','l','d','!'};
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
acc.powerOn();
}
void loop() {
// put your main code here, to run repeatedly:
if (acc.isConnected()){
for(int x = 0; x < ARRAY_SIZE; x++) {
Serial.print(hello[x]);
delay(250);
}
Serial.println();
delay(250);
}
}
我的错误返回:
ExtendHelloWorld:10: error: 'AndroidAccessory' does not name a type
ExtendHelloWorld.ino: In function 'void setup()':
ExtendHelloWorld:17: error: 'acc' was not declared in this scope
ExtendHelloWorld.ino: In function 'void loop()':
ExtendHelloWorld:22: error: 'acc' was not declared in this scope