In order for your Android phone or tablet to host a USB device such as an Arduino, you need aOn-The-Go (OTG) USB cable. You can buy these for a few bucks online, but if you have an old USB cable around it’s more fun to make one!
All you need are two donor USB cables, one with a female type A end like you’d find on a USB extension cable (shown in the first photo here) and one with a male micro B end (second photo). When you’re finished, you’ll have a cable that plugs into your phone on one side and accepts a standard USB cable on the other.
First, cut your 2 donor cables to expose the red, black, white, and green wires within, and strip the insulation off the tips.
Match up the wire colors from both sides of your soon-to-be Frankencable and solder them together. Insulate the soldered joints from each other using shrink tubing, electrical tape, or hot glue. Don’t forget to connect the braided shielding as well — that’s the uninsulated stranded wire that surrounds the 4 colored wires.
After splicing the 2 cables together, wrap the junction in electrical tape for protection and strain relief.
Many Android phones are USB On-The-Go devices, which means they can act as the USB host (providing power) or slave (receiving power). You want the phone to be the USB host for this project, and you can ensure it acts as such by means of a special Sense pin on the micro B connector.
When the sense pin is connected to ground, the USB OTG device attached to the cable enters host mode. If the sense pin is left in its usual disconnected state, the USB OTG device will remain in slave mode.