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.


4 Answers 4


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).


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.

  • Half you answers refer to this product. Are you associated with it? You need to disclose any personal stake in it if you are. Commented Oct 2, 2014 at 20:22
  • not associated with the company, but a happy customer of their product.
    – albator
    Commented Oct 13, 2014 at 19:07

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


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)

    //Add layout to app.    

    //Create USB serial object.
    usb = app.CreateUSBSerial() 
    if (!usb) {
        app.ShowPopup("Please connect your Arduino and restart")

//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) {

Arduino code:

void setup() {
  loop() {
    if (serial.Read()="ledh) {
    if (serial.Read()="ledl) {
  • 2
    The Arduino code has clear syntax errors; please review.
    – tripleee
    Commented Jul 28, 2022 at 5:00
  • 2
    this doesn't answer the question. OP wants to use USB HID capability (emulate keyboard) of the Leonardo
    – Juraj
    Commented Jul 28, 2022 at 5:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.