First, to set the stage:
Installed/Using:
Android Galaxy S3 Mini (4.1.2)/ Galaxy Nexus (4.2.2)
Mega-ADK 2560 R3
Arduino 1.0.5
Processing 2.09b
SDK Tools for android _r22.0.1 (and much much more)
I'm trying to upload the following code from a Tellart android+arduino+processing example tutorial. I know the example might not work but the trouble is I can't even get it compiled in the Arduino sketch.
////////////////////////////////////////////////////////////
//NEEDED FOR ALL ARDUINO ADK sketches
////////////////////////////////////////////////////////////
#include <Max3421e.h>
#include <Usb.h>
#include <AndroidAccessory.h>
// accessory descriptor. It's how Arduino identifies itself to Android
char applicationName[] = "Mega_ADK"; // the app on your phone
char accessoryName[] = "Mega_ADK"; // your Arduino board
char companyName[] = "Freeware";
// make up anything you want for these
char versionNumber[] = "1.0";
char serialNumber[] = "1";
char url[] = "http://labs.arduino.cc/adk/"; // the URL of your app online
//initialize the accessory:
AndroidAccessory usb(companyName, applicationName,
accessoryName,versionNumber,url,serialNumber);
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
// button variables
int redPin = A0; //analog 0
int greenPin = A1; //analog 1
int bluePin = A2; //analog 2
int redVal;
int greenVal;
int blueVal;
long timer = millis(); // counter to track last time we sent values
void setup() {
usb.powerOn(); // start the connection to the device over the USB host:
}
void loop() {
// Read the RGB Pots
redVal = analogRead(redPin) /4;
greenVal = analogRead(greenPin) /4;
blueVal = analogRead(bluePin) /4;
// Print to usb
if(millis() - timer > 100) { // Has it been over 100ms since last send?
if (usb.isConnected()) { // isConnected makes sure the USB connection is open
usb.beginTransmission();
usb.write('R'); //SEND R for red, and the red value
usb.write(redVal);
usb.write('G');
usb.write(greenVal);
usb.write('B');
usb.write(blueVal);
usb.endTransmission();
}
timer = millis(); //reset the timer
}
}
This is exactly how I have typed it in. My error reads the following:
RGB_arduino.ino: In function 'void loop()':
RGB_arduino:53: error: 'class AndroidAccessory' has no member named 'beginTransmission'
RGB_arduino:55: error: no matching function for call to 'AndroidAccessory::write(char)'
C:\....\Arduino\libraries\AndroidAccessory/AndroidAccessory.h:27: note: candidates are: int AndroidAccessory::write(void*, int)
RGB_arduino:56: error: no matching function for call to 'AndroidAccessory::write(int&)'
C:\....\Arduino\libraries\AndroidAccessory/AndroidAccessory.h:27: note: candidates are: int AndroidAccessory::write(void*, int)
RGB_arduino:58: error: no matching function for call to 'AndroidAccessory::write(char)'
C:\....\Arduino\libraries\AndroidAccessory/AndroidAccessory.h:27: note: candidates are: int AndroidAccessory::write(void*, int)
RGB_arduino:59: error: no matching function for call to 'AndroidAccessory::write(int&)'
C:\....\Arduino\libraries\AndroidAccessory/AndroidAccessory.h:27: note: candidates are: int AndroidAccessory::write(void*, int)
RGB_arduino:61: error: no matching function for call to 'AndroidAccessory::write(char)'
C:\....\Arduino\libraries\AndroidAccessory/AndroidAccessory.h:27: note: candidates are: int AndroidAccessory::write(void*, int)
RGB_arduino:62: error: no matching function for call to 'AndroidAccessory::write(int&)'
C:\....\Arduino\libraries\AndroidAccessory/AndroidAccessory.h:27: note: candidates are: int AndroidAccessory::write(void*, int)
RGB_arduino:64: error: 'class AndroidAccessory' has no member named 'endTransmission''
So my question is:
What is beginTransmission, why isn't it compiling? Am I missing files or do I need to alter libraries?