Slide 35
Slide 35 text
Basic firmware/sketch on Arduino ADK
#include
#include
#include
AndroidAccessory acc("Manufacturer", "Model",
"Description", "1.0",
"http://www.android.com",
"0000000012345678");
Google-supplied C++ library
USB and USB host libraries
Create a new instance of the AndroidAccessory
void setup() {
acc.powerOn();
}
void loop() {
byte msg[0];
if (acc.isConnected()) {
//send something to the Android app
acc.write(msg, 1);
//or read something
int len = acc.read(msg, sizeof(msg), 1);
}
}
Note: You can get a fully working but barebones Arduino ADK sketch here: iheartrobotics.com/2011/07/arduino-mega-adk-setup-notes.html
Convenience method that simply calls the
powerOn() method in the Max3421e library.
Continually check for connection to Android app
Create data that the Android app can read
Read data from Android app into msg variable