How to tell if an Android device has Open Accessory Mode

前端 未结 5 696
旧时难觅i
旧时难觅i 2021-01-24 11:01

Does anyone know how to check for this? I just bought a Samsung Galaxy Tab 2 (7\" version running Android 4.0.3) with the intention of using it to connect to my Arduino Mega ADK

5条回答
  •  执笔经年
    2021-01-24 11:36

    I don't know how you can find out if your device has this ADK mode (I failed trying to follow that lead when trying to get my stuff set up.) But here are a few gotchas I figured out:

    make sure you are using Arduino IDE v1.0, I was trying 23 for a while. But you must use the newset one.

    I also had to edit the sketch in order to get it working. Here was my new setup method. I just added some print statements so I could tell which portion it was failing at. It turned out for me the init_joystick ( 5 ); call was where it was dying. I commented that out and all went well.

    void setup()
    {
        Serial.begin(115200);
        Serial.print("\r\nStart");
    
        init_leds();
            Serial.print("\r\nDone LED");
        init_relays();
            Serial.print("\r\nDone Relay");
        init_buttons();
            Serial.print("\r\nDone button");
        //init_joystick( 5 );
    
    
        // autocalibrate OFF
        touch_robot.set_CS_AutocaL_Millis(0xFFFFFFFF);
    
        servos[0].attach(SERVO1);
        servos[0].write(90);
        servos[1].attach(SERVO2);
        servos[1].write(90);
        servos[2].attach(SERVO3);
        servos[2].write(90);
    
    
        b1 = digitalRead(BUTTON1);
        b2 = digitalRead(BUTTON2);
        b3 = digitalRead(BUTTON3);
        //b4 = digitalRead(JOY_SWITCH);
        c = 0;
    
        acc.powerOn();
            Serial.print("\r\nDone Setup");
    }
    

    This change to the Setup method in the ADK demokit sketch allowed the connection to be registered and for the app to do its other nifty things.

    However, I only tested on devices that I knew supported the ADK :

    • Galaxy Nexus
    • Nexus S
    • Motorola Xoom

    You will have to provide sufficient power to the ADK device - at least Nexus S can be unstable when the ADK device is powered from a USB hub. Telltale signs are ADK mode flaking out for no apparent reason.

提交回复
热议问题