1

I'm trying to connect Arduino Leonardo to an Android tablet. I would like to make the Arduino send commands (using pushbuttons or a slider for example) to the tablet to switch between pages, to select a file on the desktop, to scroll up and down the screen, etc.

ocrdu
  • 1,795
  • 3
  • 12
  • 24

4 Answers4

1

Perhaps this is not exactly what you are looking for, but from your examples it seems like using navigational commands from the keayboard/mouse would accomplish a lot of what you are requesting.

Android has USB HID support from honecomb, so you should be able to create a sketch to emulate a keyboard and mouse based on the IO data and it should work with your android device just by plugging the USB cable (if emulating a mouse, it will display the mouse cursor as soon as it is connected).

carlosperate
  • 151
  • 2
-1

First, get a Lightblue Bean, http://punchthrough.com/bean/

It has everything you need: - arduino - bluetooth - API - code example - android sdk - ...

Develop your product using this platform.

If you want to scale and build your own platform, then you will have a foundation to validate your work.

albator
  • 109
  • 2
-1

It is a good idea to use a LightBlue Bean, only if you are using the Android SDK! https://bitbucket.org/littlerobots/beanlib

You can read more about the SDK, and get advice from people who are actually using it. http://beantalk.punchthrough.com/t/announcing-unofficial-android-sdk/394

-1

Android code:

function OnStart() {
    //Create a layout with objects vertically centered.
    lay = app.CreateLayout("linear", "VCenter,FillXY")
//Create a toggle button.
btn = app.CreateToggle("LED On/Off", 0.4)
btn.SetOnTouch(btn_OnTouch)
lay.AddChild(btn)

//Add layout to app.    
app.AddLayout(lay)

//Create USB serial object.
usb = app.CreateUSBSerial() 
if (!usb) {
    app.ShowPopup("Please connect your Arduino and restart")
    return;
}
usb.SetOnReceive(usb_OnReceive)
app.ShowPopup("Connected")

}

//Called when user touches our toggle button. function btn_OnTouch(isChecked) { if (!usb) return;

//Send LED command to Uno.
if (isChecked) usb.Write("ledh")
else usb.Write("ledl")

}

//Called when we get data from Espruino. function usb_OnReceive(data) { console.log(data) }

Arduino code:

void setup() {
  pinMode(2,1);
  serial.begin(9600);

loop() { if (serial.Read()="ledh) { digitalWrite(2,1); } if (serial.Read()="ledl) { digitalWrite(2,0); } } }

ocrdu
  • 1,795
  • 3
  • 12
  • 24