How do I write an Arduino sketch and an Android application to talk to each other over a standard USB cable?
Android devices usually don't have a USB host: they expect to be connected to some smarter device like your computer. Same goes with Arduino. For this reason Arduino made the Mega ADK (that means Accessory Development Kit).
Mega ADK and Due act as USB hosts and can be connected directly to your Android phone. If you already have a board, another option is to get a USB host shield to add USB host capababilities.
Your sketch will tell the phone what kind of accessory application it is and your phone will download the appropriate application from the store.
There is a book about connecting Arduino to Android.
You never mentioned your tablet model... or Arduino model
There are some tablets designed to work with USB flash drives and printers. This is called OTG (on the go.
- A tablet supporting OTG
- An OTG adapter that fits into your tablets USB slot and is compatible
- The Arduino Uno Communicator App
- Arduino Uno (or clone) [Note: It says that it works with Atmega16U2 or Atmega8U2 programmed as a USB-to-serial converter so I would assume that that would cover a few boards more than the Uno.)
Another alternitive is to look into Bluetooth (Note: I just picked a random link but there are hundreds of similar BT adapters)
The USB protocol requires one end to be a "host" and the other end to be a "peripheral", and it doesn't work if the devices at both ends of the cable are "peripherals". Alas, most Arduinos and many early Android devices are "peripherals", so connecting such devices with a standard USB cable doesn't work.
Some modern Android devices support "OTG", so in theory one could make the Android end of the cable the "host". Has anyone gotten this to work?
Another approach is to somehow make the Arduino end of the cable the "host", and the Android end of the cable the "peripheral". That's the approach taken by
Processing is a great place to get started with device to device communication.
The interface and language are very similar to Arduino and there are many examples to get you started.
You can connect Android and Arduino with usb and use the easy tool App inventor 2 for android
Did you try this new application : https://play.google.com/store/apps/details?id=bp.usbbridge.appinvDemo and full version : https://play.google.com/store/apps/details?id=bp.usbbridge.appinv
Find Videos about Explications : USB OTG Bridge Serial UART for APP Inventor 2 and ARDUBLOCK on youtube