Arduino meets Android USB Host Shield and ADK Serial Communication Library

In previous post of mine (here) I wrote about communication between Arduino and Android with using OTG cable.But there are many ways to establish a connection between Arduino and Android.

usbshield

Using USB Host Shield is one of these methods.To be able to use a USB Host Shield you will need this library. I have used this library because it has a pretty wide device support and it is stable.

Even if you use the library , your code will still be complicated.For example this is an example code for receiving and sending data:

 

 

So I started to think that I must simplify this and I wrote a library.
Library is based on string commands.You should register a function for your every command.The function will be called when the string you choose is sent from Android. Register it like this :

This is the simplified version of receiving data and acting to it :

 

 

 

All you have to do is listen in every loop cycle.And do not forget to change USB prefs from CSerialCom.cpp

 

You can download the library and its example from github.

And also to test it , you can download Android application from here.By the way ,the project is created on Xcode but still you can use cpp files and library.About how to use Xcode on Arduino development you can check out here.

Stay curious,

Aykut Celik.

Leave a Reply

Your email address will not be published. Required fields are marked *