Posts

Showing posts with the label ADK code example

Android code sending command to Arduino Due to turn LED On/Off

Image
It's the coding in Android side to send command to Arduino Due to control LED On/Off. Modify AndroidManifest.xml to add <uses-feature> of "android.hardware.usb.accessory", <intent-filter> of "android.hardware.usb.action.USB_ACCESSORY_ATTACHED", and <meta-data> of resource="@xml/myfilter". <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.androidadkled" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="12" android:targetSdkVersion="17" /> <uses-feature android:name="android.hardware.usb.accessory"/> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" ...

Hello World ADK: Communication between Arduino Due and Android device

Image
The former post demonstrate half " Pre-Hello World for ADK ". It's further implemented to include communication between Arduino Due and Android Device. In Arduino Due side: it monitor any incoming data from accessory, and send it back. In Android side, it will send out the text when Send button clicked. And display the text received from USB. It implement the function of bi-direction communication between Arduino Due and Android Device. The code in Arduino side is listed here: #include "variant.h" #include <stdio.h> #include <adk.h> // Accessory descriptor. It's how Arduino identifies itself to Android. char applicationName[] = "HelloADK"; // the app on your phone char accessoryName[] = "Arduino Due"; // your Arduino board char companyName[] = "Arduino-er"; // Make up anything you want for these char versionNumber[] = "0.1"; char serialNumber[] = "1"; char url[] = "https://sites.google.com/si...

Pre-Hello World for ADK

Image
It's a very simple incomplete "Hello World" for ADK, working on Arduino Due with Android Device. In Arduino Due side, it simple loop to detect if adk isReady(). If adk ready turn on L led, if not turn it off. Also define the URL to download the app if not installed. #include "variant.h" #include <stdio.h> #include <adk.h> // Accessory descriptor. It's how Arduino identifies itself to Android. char applicationName[] = "HelloADK"; // the app on your phone char accessoryName[] = "Arduino Due"; // your Arduino board char companyName[] = "Arduino-er"; // Make up anything you want for these char versionNumber[] = "0.0"; char serialNumber[] = "1"; char url[] = "https://sites.google.com/site/arduinosite/exercise/helloadk/HelloADK_0.0.apk"; USBHost Usb; ADK adk(&Usb, companyName, applicationName, accessoryName,versionNumber,url,serialNumber); // Pin 13 has an LED connected on most Arduino boa...