We have developed in protoboard the following schematic for driving a DC motor with transistor for Arduino, but instead of using the PN2222 transistor, we are using a MOSFET IRF540, and instead of flywheel diode 1N4001 we are using 1N4007. Also we have a LED strip connected to Arduino.
When we were developing in protoboard we were able to control the motor kickback when switching off with an 1N5819, but when did the PCB the diode is not enough. Trying different diodes didn't solve the problem, finally we are using a 1N4007 but still having issues when the motor switches off. The issue is the LEDs animation is affected: we paint in one color but sometimes when the motor switches off, some LED is painted red and the code is not programmed for that. So I guess is something related to the motor. We can't connect the motor to an alternative power supply, and also we can't solve it because what we did to solve it when using a protoboard was using a diode, and we don't understand well the problem.
We have been researching, searching on the internet but we don't understand snubber schematics, we tried with ferrite and concluded is something related to the motor when switches off and we can't control with this diode. Also we have tried SR5100 because we saw here he is using an SB320 and when I bought the SB320 I received SR5100... also, reading in this web about this topic, I tried to develop an snubber circuit, but I don't understand this video so I can't try it.
Also tell you that the motor is a vibration motor, and when I set less power with a potentiometer it is not making trouble with LEDs. The difference between the first link and our project is also that the motor is not turning free, it is a vibration motor and the implementation of an ArduinoToBreadboard.
EDITED:
The diode is soldered in the motor and is not shown in the schematic because when tried it on the breadboard didn't work, only worked when put the nearest to the motor possible.
EDITED:
Added decoupling capacitor.
EDITED:
Moved decoupling capacitor to correct place (closest to MCU as possible).