Pwm on a DC motor

A diode is important to reduce spikes. It MUST be present. (connected kathode to 12V)