My problem is that while the motors are running I see that led13 (the red led on the schematic) flashes periodically, while it's not supposed to (my code doesn't use that pin at all). After a while my atmel328 chip is kind of "erased" and in order to make my robot work again, I have to reprogram the chip.
So after looking around I found out that my h-bridge doesn't come with protection/flyback diodes (correct me if I'm wrong) and I need to add them myself. I have some 1N40001 diodes but am not sure how and where to connect them. Should I connect parallel to the motor leads? And if so, what the polarity should be given that the polarity can change (the motors run in both directions). Alternatively, should I connect the diodes serially to the wires connecting the Arduino digital pins to the driver input pins on the h-bridge?