Control USB device

Hi everyone,

I'm very new with arduino and even electronics thinking.

here is project I'm starting.
let's say I have my phone plugged to my PC through a USB cable.
Now I want to control under condition whether the phone shall be connected or not.
By 'connected' I mean the phone shall charge, and data exchange shall be possible
If not 'connected', then the phone does not charge, and of course no data exchange possible (the phone is not visible on the PC)

I spent hours trying to do this.

I cut first the red and black cables, and put them on the arduino, first without plugging the remaining cables (red and white) on the PC.
I was able to control the charge of the phone.

I thought it was OK, but then I plugged the USB cable on the PC (so the USB cable just have the green and white cable now), but the phone was not recognized on the PC, no data exchange possible...

instead of plugging directly the red and black cable on the arduino, I added a mosfet,
I was able to control the charge (without the USB cable plugged on the PC), but once I plugged the USB cable (so the green and white cables) I noticed I was able to exchange data with the PC, but not able to control the charge anymore. It was always charging.
I even realized it was working the same if I disconnect the back cable (not plugged at all!), data exchange possible, phone is charging always, and not means to power off.
My guess is because the white cable is linked to the "-" of my PC so it breaks my mosfet circuit.
Power is always there.

I tried to control the "+" with the mosfet and not the "-", but it sounds like it is not possible.
When I do that power is always there, even without the white and green cables plugged on the PC.

I think my last attempt will be with a "dry contact", I will only cut the red cable this time.
I assume this will work.

Do you know if there is a means to do this with simple items? like just a mosfet?


Your phone must be powered whenever you connect it to an USB port, so that it can tell the PC that it is a phone (etc.)

Also the Gnd line must stay connected, all you can do is controlling the other lines. Dunno about wire colors, your text reads like a movie script where a bomb shall be deactivated by cutting either the blue or red cable :-]