Arduino Mega2560 Runs but Cannot Upload New Sketch


I’m using an arduino in my project and I’ve run into a problem. We’re controlling 6 motors via a custom built h-bridge motor drivers. There are 3 PCB boards. Each PCB board:-
-has two motor drivers.
-has a 12v supply.

Each motor driver has:
-2 signalling wires to arduino.
-2 wires to DC motor.

So essentially there are 3 batteries powering 6 drivers. Each battery powers two motor drivers, in parallel. I’ve tried to illustrate the circuit with a quick sketch (attached below). I’ve also attached the schematic of the H bridge. I stress again, the boards work and have been tested individually.

I set up the circuit attached, but DID NOT power the arduino with the 12V battery, instead, it was powered from a USB cable using a laptop. Aftering up loading several programs, i uploaded a program to test each of the motors (firing one at a time). This worked fine.

I then took out the usb cable from the laptop, and plugged in the 12v battery to the arduino. That is the circuit in the picture I have attached (imag0147). This resulted in a motor firing at random.

We unplugged the battery and used the USB cable again. The program runs as before - but we cannot upload new sketches to the arduino. The device manager recognises the board on the laptop, but when trying to upload the sketch, it hangs.

I’ve tried hitting reset on the arduino and then uploading within two seconds, and the laptop says ‘COM 3 is busy - port in use. Close any programs that may be using it.’

The laptop has been restarted, system restored. The cable has been changed. The program on the arduino still runs, but we cannot upload new ones.

Any ideas or is this a common problem??