Example Connection between USB Host and Android
This example illustrates the connection between Board ET-MEGA2560-ADK and Android through Port USB Host. In this case, it develops program by ADB (Android Debug Bridge) by using Library ADB of Microbridge. This example is compatible with every Android devices versions that have been installed the Operating System of Android version V1.5 and higher. It divides part of developing program into 2 parts. Firstly, it develops program in the part of Microcontroller (ET-MEGA2560-ADK); and secondly, it develops program in the part of Android device. In this case, it uses Program Android SDK to develop Application of Android. There are many websites that have published information about developing program for board by ADB (Android Debug Bridge); in this case, we recommend the
official website of
Android Versions
Android is the operating system as Open Source Project from Google; it is suitable for mobile devices, especially Android Mobile Phone and Android Tablet. This Operating System of Android from Google is Open Source that can be developed and improved independently; so, it attracts many developers around the world to share the knowledge and develop program to supply requirement until it is a large community. It uses JAVA Language with Library of Google called “Google Developed Java Libraries” to develop program. Google continues improving and modifying the Library and nowadays there are more than 10 versions.
Android version is specified by name code (Nick Name) and API Level; however, some details are different. So, code and Compiler version must be matching, otherwise it cannot compile any code program.
Android Version API Level
Name Code version (Nick name)
Android Open Accessory Development Kit (ADK)
ADK is Android Program Development Kit that allows external USB Host device to interface with Android Operating System such as Android Phone and Android Tablet in the Accessory Mode; so, Android device can act as Host. Most devices are cheap such as mobile phones; it can communicate with external device through USB Bus according to conditions and restrictions of ADK. The format of Protocol ADK can reduce difficulty in communicating through USB of mobile phones. In this case, it moves the difficulty in communicating to the side of USB Host that is the outside of mobile phone instead.
This capability is compatible with devices that have been installed the Android Operating System from version 2.3.4 (for old version that has been released) to version 3.1(for new product release). Accessory devices that are interfaced with Android devices in this operation mode must has own Power Supply; moreover, it cans also supply 5V/500mA to Android device to charge current for Android device.
Android Debug Bridge (ADB)
This is the format of developing program that is Application for external devices; so, Android device can communicate and command various Input/output with external devices. In this case, user can apply cheap Android devices in the market for many applications; it seems to increase unlimited Input/Output systems into mobile phones. This capability is included in all Android device versions that have been installed the Operating System version 1.5 or higher; so, it can support almost devices in the market that have been installed the Operating System of Android.
If interfacing Board ET-MEGA2560-ADK with mobile phone that has been installed the Operating System of Android, it looks like Board ET-MEGA2560-ADK acts as I/O of mobile phone; moreover, it is controlled and commanded by mobile phone through Cable USB. So, it seems that the mobile phone has the system of Input/Output that is both Digital and Analog, including other special Input/Output such as I2C, PWM, USART and so on.
The following example is a guideline to connect Android device with Board ET-MEGA2560-ADK; this example is modified from Library ADB of Microbridge. It uses the capability of GUI that uses touch screen and the display screen of mobile phone to command and display operating result of Input/Output of Board ET-MEGA2560-ADK. The operating result of program is to command ON/OFF LED(D13) on Board ET-MEGA2560-ADK according to the control of touch screen. In the meanwhile, Board ET-MEGA2560-ADK sends the result of converting signal from Analog(ADC0) and then sends back to the Android device.
How to test operation
The method to test the operation of this example is to develop program for 2 sides; Microcontroller and Android device. On the side of Microcontroller, it uses Board ET-MEGA2560-ADK and it develops program through Program Arduino with ADB Library of Microbridge. On the side of Android device, it uses computer PC with Program JAVA and Android Library of Google to be tool to develop program.
First of all, user has to compile and upload program in the part of Microcontroller into Board ET-MEGA2560-ADK by Program Arduino first. Moreover, user has to copy Library ADB for AVR Microcontroller that has been developed and modified by Microbridge and then paste it in the Folder “..\arduino-0022\libraries”. So, signals can directly interface with Hardware System of Board ET-MEGA2560-ADK as shown in the example below;
How to prepare ADK Development kit
1. Download and install Program JDK (Java Developer Kit) 2. Download and install Program Android SDK
3. Download and install program Eclipse IDE
4. Install Program ADT (Android Development Tool) Plugin
1. Download and install Program JDK (Java Developer Kit). This is Java Language Program that includes various essential Libraries to develop program for Android. User can directly download and install the program from web page;
Load from:
2. Download and install Program Android SDK. User has to choose and set values according to the actual Operating System that has been installed in computer PC. If using with Windows, there are 2 choices; Zip File and Install File. In this case, it is better to choose version File Install because it is more convenient. When user has downloaded the program successfully, should install in Folder “C:\android-sdk-windows” because it is more convenient to call. Next, choose Package for installation as Accept All; in this case, it takes a long time for processing.
3. Download and install Program Eclipse IDE.
4. Install Program ADT (Android Development Tool) Plugin. This Program ADT links files and sub-programs that are essential and related to develop program for ADK; so, it is more convenient to call and command program through window IDE of Program Eclipse correctly. User has to install this Plugin while connecting Internet; click Menu Help Install New Software…
Set values in the window Install completely. Firstly, set the value in the blank of Work with as Add…; secondly, set Path value for downloading Program Plugin by setting Name as
ADT; thirdly, set Path value in the blank of Location: as
https://dl-ssl.google.com/android/eclipse/; and finally, click OK. User has to wait for a while and the program shows additional Developer Tools, user has to tick the check box and click Next to go to the next step.
Testing Example Application
1. Copy the example program that has been developed by ADK; paste and save in the Hard Disk as shown in the example below;
Click Menu File Import…; choose Existing Projects into Workspace; click Next and finally, click “C:\DEMO_MEGA2560_ADK”
After user has already set Directory successfully, the program shows lists of all Project File in the Directory; in this case, user can tick check box in front of the Project File that user requires Import to test the operation.
Next, click Menu Project Properties and choose Tab Java Compiler. User has to choose the Compiler version according to the Operating System of the device that is used with program development; in this case, user has to choose Enable Project Specific Setting and set the value as Compiler Compliance Level completely.
After user has compiled successfully, it displays the operating result in the format of File “Mega2560ADKV233Demo.apk” and it is saved the Folder “C:\DEMO_MEGA2560_ADK\Mega2560ADKV233Demo\bin“; in this case, user can install this file into the Android device instantly. If user has already installed Driver of Android device into computer PC and connected USB Cable between computer PC and Android device completely, user can run the operation from Program Eclipse instantly. Program transfers files to Android device automatically.