Why use a diode with a dc motor

I know that using a diode with a dc motor helps the current from damaging the transistor and arduino when the motor is powered off. But take a look at this simples image:

When the motor is on th diode has no function cause current is not flowing inside it. When the motor is off, at that momento, some current will be generated by the motor (if it keeps spinning) but it would be generated in the upper part of the diode (in the image above) so this current would like some place to go but there is none cause the transistor will not allow it to pass and the 5V of the arudino is a source of energy. So where will this current generated by the motor goes? And how, phisically, the diode helps in anything?

This is a reasonable explanation

How do you hide the link behind a word like that ?

[url=real link]word in text[/url]

the button with the "chain" left of the mail button

The link you provided me helped a lot! It’s very good! But I still have one question in the image below:


A voltage is initially aplied to the + of the coil. The diode prevents the current going inside it so the current has to go inside the coil to the ground -. What does prevent the current to come back to the + after it passes the coil since the diode would allow the current to go up inside the diode in the image above.

Thank you!

That site is designed to confuse since its using a negative supply voltage and PNP
transistor, which is almost never used.

Just think of it this way - the diode provides a path for current to flow if the transistor
switches off rapidly, the inductance of the motor windings means that the current cannot
suddenly stop, it must wind down as the magnetic field energy converts back to electrical
energy. Coils generate whatever voltage is necessary to ensure the current flows, so
you have to provide a path for current, not try to prevent it.

The higher the voltage the more rapidly the current decreases though, diodes have the
downside that the current circulates for a while since there’s only about 1V at most.