Question

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.

Was it helpful?

Solution

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.

OTHER TIPS

It seems:

  acc.powerOn()

can be replaced with:

  acc.begin();

Try to use Arduino 0.22 or 0.23 IDE

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top