Serial communication while powering 12V motor

So I've setup my circuit according to this image:

Using a 12V lead acid battery as the external power.

Everything works fine when the motor is off, but whenever I run the motor up to about 25% power, the serial monitor freezes and I get a USB device malfunctioned error on my computer. This also kills my mouse, and if I try to do any more communication I get an error telling me COM3 port already in use. Strangely, serial communication is the only thing to malfunction, I'm testing the setup by cycling the motor through periods of 0-100% power and the motor continues to work even after communication cuts off.

I've tried attaching a 9V battery to the arduino power input, as well as using a different computer without any luck. Any advice?

From this post:
http://forum.arduino.cc/index.php?topic=58217.0

I attached a 0.1uF capacitor across the motor and a 470uF capacitor on the arduino power rails, and I can now make it to about 60% power before losing communication. So I guess the solution is a bigger capacitor.

the serial monitor freezes and I get a USB device malfunctioned error on my computer.

You are somehow overloading the USB port on the pc. You probably have bad wiring such that the arduino is shorting out when the motor attempts to run.

tyrantbb:
I attached a 0.1uF capacitor across the motor and a 470uF capacitor on the arduino power rails, and I can now make it to about 60% power before losing communication. So I guess the solution is a bigger capacitor.

If it is really wired according to your diagram I can't see how anything on the Arduino could be overloaded.

From your experience with the capacitors the motor seems to be causing interference. Is your diode working properly?
Does it make any difference if you move the motor relative to the Arduino? If you could put an equivalent resistive load in place of the motor (perhaps a suitable bulb) it might help to prove that.

...R

Is it possible to paste your code & Screen shot of error

the serial monitor freezes and I get a USB device malfunctioned error on my computer.

Please check IC gets heats up while it hangs serial monitor.Requested to send code.

I don't have a screen shot of the error, as I have fixed the issue but the code I was trying to run is:

for(userSpeed = 0; userSpeed < 100; userSpeed +=1)
{
motorSpeed = map(userSpeed, 0, 100, 0, 255);
analogWrite(motorPin, motorSpeed);
Serial.println(userSpeed);
delay(100);
}
for(userSpeed = 100; userSpeed >= 1; userSpeed -=1)
{
motorSpeed = map(userSpeed, 0, 100, 0, 255);
analogWrite(motorPin, motorSpeed);
Serial.println(userSpeed);
delay(100);
}

The problem was fixed by adding three capacitors to the motor, twisting the motor wires and adding a 1000 uF capacitor on the arduino power rails.