Arduino-Android communication

I want an Arduino and an Android phone to communicate to each other. I bought an USB host shield, and according to the information I found on the internet related to this issue, downloaded the necessary libraries, wrote an Arduino sketch and Android app. I met some compiling problems that got fixed thanks to the tips I found on the internet, but in the end, it doesn’t work. Once the sketch is downloaded to the Arduino board and the app to my mobile Phone running Android 4.4.4, I connect both devices by means of a USB micro B cable, and nothing happens, when supposedly, this should trigger the app start up. I don’t see either any print out in the Serial Monitor from the Arduino side. Can anybody tell me whether I am missing something?

Wouldn’t you rather using Bluetooth?

I ask this because you need HC-05 Bluetooth module and Arduino and a ready-made Android Bluetooth terminal app. I found it easy.

josemiguelvelasco:
I connect both devices by means of a USB micro B cable, and nothing happens, when supposedly, this should trigger the app start up.

Assuming the Arduino is sending the requisite data, which can’t be hard to do - and verify, this is entirely an Android problem. You might start by confirming that the phone is capable of communicating via USB, and then checking your Android code on an Android forum.

You may be happy to re-invent the wheel as an intellectual exercise, but AndroidArduino is a menage a trois made in heaven and, if you just want to do a proper job of communication, you might be better off on the well-trodden path - as pointed out above…

I don’t see either any print out in the Serial Monitor from the Arduino side. Can anybody tell me whether I am missing something?

Probably not, as your code is a secret.

My code following. I only see in the serial monitor the string “Al principio”

#include <Max3421e.h>
#include <Usb.h>
#include <AndroidAccessory.h>

#define ARRAY_SIZE 12

AndroidAccessory acc("JM", "MCC", "Description", "1.0", "URI", "Serial");

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);
 Serial.println("Al principio");
 pinMode(7,OUTPUT);
 digitalWrite(7,HIGH);
 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);
 }
}

I have no clue what “accessory” you are using, but clearly if you understand the code, acc.isConnected() false.