3
votes

All I'm trying to do is compile the Arduino to Android 'hello world' program from the book "Beginning Android ADK with Arduino".

Here is the code

#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);
  }
}

And my error

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

I looked in AndroidAccessory.h and sure enough it is private, but what should I change to make this work? I assume making the function pulic is not the answer.

4
Hi Eric. Did you manage to compile the code? I tried compiling on IDE v22 and v1.0.2 using the library from step 1 over arduino labs website labs.arduino.cc/ADK/AccessoryMode .I tried on windows 8 and ubuntu 12.10 with the same error like you. This is really frustratingandroidu

4 Answers

3
votes

It seems:

  acc.powerOn()

can be replaced with:

  acc.begin();
0
votes

The answer could also be that the wrong board was chosen during compile. If you choose the wrong board the Arduino software cannot decide which chip or pins you have.

0
votes

I did it! I just made the visibility of the read() function in the <AndroidAccessory.h> header public and used begin() instead of powerOn() like Mickaël said, and now the code compiles successful.