In this post, I will describe how to make ADKTerminalTest example work with ArduinoTerminal. In next post, I will show how to import and setup ArduinoTerminalSrc in Android Developer Tools. After finished, you can connect and send text between Arduino Due and Nexus One running Android 2.3.6.
| Arduino Due work with Nexus One |
![]() |
| ADKTerminalTest example in Arduino 1.5.2 |
Modify on Arduino code:
- Modify adk() parameters to match with Android side. To acknowledge the originator of Android ADK terminal emulator for Arduino, I use the original counter part.
- Add the code Serial.begin(9600) in setup() method.
/*
ADK Terminal Test
This demonstrates USB Host connectivity between an
Android phone and an Arduino Due.
The ADK for the Arduino Due is a work in progress
For additional information on the Arduino ADK visit
http://labs.arduino.cc/ADK/Index
created 27 June 2012
by Cristian Maglie
*/
#include "variant.h"
#include <stdio.h>
#include <adk.h>
/*
// Accessory descriptor. It's how Arduino identifies itself to Android.
char applicationName[] = "Arduino_Terminal"; // the app on your phone
char accessoryName[] = "Arduino Due"; // your Arduino board
char companyName[] = "Arduino SA";
// Make up anything you want for these
char versionNumber[] = "1.0";
char serialNumber[] = "1";
char url[] = "http://labs.arduino.cc/uploads/ADK/ArduinoTerminal/ThibaultTerminal_ICS_0001.apk";
*/
USBHost Usb;
//ADK adk(&Usb, companyName, applicationName, accessoryName,versionNumber,url,serialNumber);
ADK adk(&Usb,"Circuits@Home, ltd.",
"USB Host Shield",
"Arduino Terminal for Android",
"1.0",
"http://www.circuitsathome.com",
"0000000000000001");
void setup()
{
Serial.begin(9600); //<-- need to add
cpu_irq_enable();
printf("\r\nADK demo start\r\n");
delay(200);
}
#define RCVSIZE 128
void loop()
{
uint8_t buf[RCVSIZE];
uint32_t nbread = 0;
char helloworld[] = "Hello World!\r\n";
Usb.Task();
if (adk.isReady())
{
/* Write hello string to ADK */
adk.write(strlen(helloworld), (uint8_t *)helloworld);
delay(1000);
/* Read data from ADK and print to UART */
adk.read(&nbread, RCVSIZE, buf);
if (nbread > 0)
{
printf("RCV: ");
for (uint32_t i = 0; i < nbread; ++i)
{
printf("%c", (char)buf[i]);
}
printf("\r\n");
}
}
}
Next:
- Import and setup Android ADK terminal emulator, to work with Arduino ADKTerminalTest example

No comments:
Post a Comment