But in the USB OTG; some of these gadgets (which would normally play the role of 'slave') can act as 'hosts' for other gadgets.
Now a problem arises. How does a gadget (such as your smart phone) get to know the role which it needs to play (ie should it play as the host or the slave)? To answer this problem, we need to look at the pin assignment in a USB port.
A USB cable has 4 wires. 1 pair for power and another pair for data. But if you observe a mini or micro USB port which comes in a gadget like a phone or a camera, you will notice that there are 5 pins in the port. Apparently one pin is extra. That extra pin which happens to be the 4th pin (in between ground and data- pins) is the key.
If the extra (4th pin) is kept unconnected, the gadget will assume the role of the slave. This is the way a phone connects with a PC. If the 4th pin is connected to ground, the gadget assumes the role of host. This is how you need to connect a phone(host) with a pen drive (slave).
Now another important question, why do we need to create a DIY USB OTG cable? Number of mobile phones supporting USB OTG is very low. Also the number of users who are aware of USB OTG facility is even lower. Further many phone manufacturers do not not provide an OTG cable with the phone itself. Therefore it is very difficult to find a USB OTG cable in Sri Lankan market. As per my understanding only Nokia agents have this cable in their head office store at a very inflated price of about Rs 2000. But from Fort you can buy a normal USB micro (data) cable for Rs 200 and a normal USB (Regular) extension cable for Rs 100. Then you can make a USB OTG cable with only Rs 300 and litle bit of labour.
Therefore simply what we need to do in order to make a USB OTG cable out of a normal USB micro cable and a USB extension cable is
- Crack open a micro USB connector and connect 4th (extra pin) and 5th (ground pin) pins.
- Replace the male USB connector with a female one so that gadgets like pen drives can be connected (We need the the regular USB extension cable to salvage the female connector)