Go Down

Topic: [Arduino Vs Android] Open accessory protocol problem (Read 3789 times) previous topic - next topic

CG82

Hi, I just started working on Arduino and I'm trying to make the board communicate with an Android device. I've got a MEGA ADK version of Arduino.
I want to use the open accessory protocol so I tried to use this sketch someone gave to me:
Code: [Select]
#include <Max3421e.h>
#include <Usb.h>
#include <AndroidAccessory.h>

#define ARRAY_SIZE 12

AndroidAccessory acc("Manufacturer",
"Model",
"Description",
"Version",
"http://mondocrudele.com",
"0000000012345678");

char hello[ARRAY_SIZE] = {'h','e','l','l','o',' ',
'w','o','r','l','d','!'};
char alo[ARRAY_SIZE] = {'t','e',' ','l','o',' ',
's','c','o','r','d','i'};

void setup() {
  Serial.begin(9600);
  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);
  }
  else {
  for(int x = 0; x < ARRAY_SIZE; x++) {
      Serial.print(alo[x]);
      delay(250);
    }
  Serial.println();
  delay(250);
}
}

I included the libraries
<Max3421e.h>
<Usb.h>
<AndroidAccessory.h>
in the Arduino libraries folder and the sketch is successfully compiled. When I attach an Android phone to the board via USB nothing appears on the serial monitor. Am I doing anything wrong? Did I forget anything important?
I tried with the following phones:
Sony Xperia Arc, Android 2.3.4 updated to ICS, kernel 2.6.32.9
Samsung Galaxy S, Android 2.3.4, kernel 2.6.35.7
I read that Open Acc. was backported to Android 2.3.4 so I think it should work...or not? :smiley-mr-green:

PGT

Wow you have a googleIO developers day android bord   !! ??  (how did you get it?)

see http://reviews.cnet.com/8301-19736_7-20061529-251.html
the forum is pretty silent about future arduino development boards, i assume its a next level board type.
If you went to google's IO days, didnt you got a CD with programming samples ?


dxw00d

You can just buy them... http://arduino.cc/en/Main/ArduinoBoardADK

PGT


i dont think these are yet for sale ? (and not even mentioned on this site)



wd40bomber7

#4
Jul 11, 2012, 11:43 pm Last Edit: Jul 11, 2012, 11:45 pm by wd40bomber7 Reason: 1
That may be so, but it's completely irrelevant. CG82 even mentions in his post he has a MEGA ADK version of arduino which is exactly the one dxw00d linked to. They were released a while ago and you can buy them in many different locations. Also that board to the right is a spitting image of the arduino mega adk (http://arduino.cc/en/Main/ArduinoBoardADK)

@CG82 As for your problem, what do you mean serial monitor? You mean an Android serial monitor? Is there such a thing made for use with the arduino ADK? I suppose there must be. I would see if it has any description or additional requirements. (Such as android version, or serial port settings)

CG82

It's the version dxw00d posted  :)

@wd40bomber7: I mean Arduino serial monitor (tools->serial monitor on the arduino enviuronment). That code should print a sequence of characters on arduino serial port but nothing happens.

PGT

Hm, if your new to this
in the code editor, did you configure the proper board to compile for and set the right com port; (and first installed the drivers) ?
Or else nothing will happen also.

I'm wondering so there must be now a google app to do com port communication ? (your talking to a pc comport here?)
i have a galaxsy SII, if it has a com port emulation app thats kinda cool :)

wd40bomber7


It's the version dxw00d posted  :)

@wd40bomber7: I mean Arduino serial monitor (tools->serial monitor on the arduino enviuronment). That code should print a sequence of characters on arduino serial port but nothing happens.


Ok so I probably don't understand everything here. How are you connecting the Arduino Mega ADK to the Android phone? My android phone only has a head phone jack and a miniusb port. So I assumed you were using the usb port to connect to the Android phone and wouldn't be able to use it to connect to the computer. Does it have two usb ports, or am I missing something?

Another important note is that there are three serial ports actually. Serial1 Serial2 Serial3, Perhaps addressing Serial1 directly instead of simply addressing Serial some how makes a difference?

dxw00d

The Mega ADK boards have the regular Arduino USB port and a USB host port connected to the SPI bus through a MAX3421E.

dxw00d


Wow you have a googleIO developers day android bord   !! ??  (how did you get it?)

see http://reviews.cnet.com/8301-19736_7-20061529-251.html


That's last year's board. The Arduino Mega ADK board is the commercial version of it.

This year's Google I/O kit is quite nice - http://www.wired.com/design/2012/07/android-development-kit-looks-hot/

CG82

I connect Arduino to Phone via A-type usb and Arduino to PC via B-type usb port.
If I remove the line
acc.powerOn();
it recognize that nothing is connected and print this part
Code: [Select]
else {
  for(int x = 0; x < ARRAY_SIZE; x++) {
      Serial.print(alo[x]);
      delay(250);
    }


So it seems that the board is not able to power on the device. Is it possible that both the phones are not compatible with the accessory protocol?

dxw00d

How are you powering it all? The ADK board will try to charge the Android device, so if you aren't providing enough current, it won't work.

Go Up