Crashing when changing direction

Hi all. I am building a rover, and I have managed to get it working perfectly with the ability to turn and move forward and reverse, however that is at a slow speed. When I increase the speed, when I change from forward to backward, the arduino resets itself. However this is not an issue when the speed is low. Therefore I know that it isn't a problem with the code. After reading around, I suspect it is something to do with the motor not changing the polarity fast enough. I am using the arduino motor shield r3. Although I suspect that this is the case, I was wondering if you guys knew how to stop the arduino crashing and reseting everytime I change direction? Thanks!

When you rapidly reverse a motor, it will draw up to twice the stall current. This is overloading the power supply and resetting the Arduino.

Partial fix: set the motor speed to zero (or brake), then wait a fraction of a second before reversing.

Better: don't power the Arduino from the motor power supply, or add good decoupling (perhaps a diode and 1000 uF capacitor).

Or even better, ramp the speed up and down, don't slam to full reverse.

Thanks for the replies. How do I decouple it? Like, how do I arrange the diode and the capacitor?

The diode prevents the capacitor discharging back through the motor, the capacitor holds the supply up that goes to the Arduino only.

For the diode/capacitor option, try this -- it is a "quick n dirty" solution.