Go Down

Topic: Arduino ADK needs to be interpreted as USB keyboard for Android Tablet (Read 1 time) previous topic - next topic

MOSFET

So far, here is the ADK program. Originally it was a simple debounce program that turned LEDs on/off. At the moment it issues a Serial.write command when a given button is pressed. It is worth pointing out one of the buttons is a N.O. SPST switch while the other is a N.C. SPST switch and thus, the program is written to accommodate this feature (which I cannot change).

Code: [Select]
/* Arduino ADK run-time program
* Author:    omitted
* Last Mod:  3/2/12
*
*/

const int pedalL     = 6;    // pin PE4, left pedal
const int pedalR     = 7;    // pin PE5, right pedal

const int outPinL    = 1;   // will become TX2, currently PL0
const int outPinR    = 1;   // currently PL1

int debounce   = 20;   // number of ms to wait for debounce

int readStatusL;
int readStatusR;


void setup()
{
    Serial.begin(115200);
    delay(2000);// Give reader a chance to see the output
    pinMode(pedalL, INPUT);
    digitalWrite(pedalL, HIGH);    // Rpu on
    pinMode(pedalR, INPUT);
    digitalWrite(pedalR, HIGH);    // Rpu on
    //pinMode(outPinL, OUTPUT);
    //pinMode(outPinR, OUTPUT);
    delay(2000);
}

void loop()
{  
    //Serial.println(1);
    readStatusL  = digitalRead(pedalL);
   
    if (readStatusL == LOW)
    {
        delay(debounce);
        if (readStatusL == LOW)
        {
            //digitalWrite(outPinL, HIGH);
            Serial.write(0x13);
            //Serial.println(2);
        }
        else
        {
            //digitalWrite(outPinL, LOW);
            //Serial.println(3);
        }
    }
   
    if (readStatusL == HIGH)
        //digitalWrite(outPinL, LOW);
   
    readStatusR  = digitalRead(pedalR);
   
    if (readStatusR == HIGH)
    {
        delay(debounce);
        if (readStatusR == HIGH)
        {
            //digitalWrite(outPinR, HIGH);
            Serial.write(0x14);
            //Serial.println(4);
        }
        else
        {
            //digitalWrite(outPinR, LOW);
            //Serial.println(5);
        }
    }
   
    if (readStatusR == LOW)
    {
        //digitalWrite(outPinR, LOW);
    }
}


Ok so it is my understanding that issuing a Serial.write command will write the data (hopefully in hex) to the transmission port (pin 1) and if I recall correctly this is linked directly into the USB shield on the ADK board. So my problems complicate because I want to connect the ADK via USB to an Android Tablet (currently running Honeycomb) and get the tablet to recognize the ADK as a keyboard input. The purpose behind this is I have written an android app that uses the up and down arrows on the keyboard (KEYCODE_DPAD_DOWN and KEYCODE_DPAD_UP are the Android scancodes which translate to 0x0014 and 0x0013 in hex). This works with a normal USB keyboard and also with a Bluetooth pedal (PageFlip Cicada) that issues the up and down arrow key commands.

Now as it stands, here is what I have read about trying to implement this feature.
http://source.android.com/tech/input/keyboard-devices.html  Talks about keyboard devices in general
http://developer.android.com/guide/topics/usb/adk.html   Talks about Using Android Open Accessory Dev. Kit

So in short I am a little stuck. If you need more information please post your specific questions and as always feedback is appreciated.

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy