Why use a flyback diode?

Here's a simulation of a fly back diode across an inductor modeling a coil (motor, solenoid... etc). This shows the effect of having one and not having one so you can compare the difference. You can try it with actual motor and components but aside from damaging things it’s next to impossible to see this and measure it. The modeling is supported by differential equations which you can use to calculate this also.

Here's the circuit with a flyback diode:

here's the simulation with a flyback diode: notice the current through the diode (ID1) and compare that to the current through the transistor when it’s on... it’s transient but it’s there.

here's the simulation without one - notice the voltage at VC - yes that's 3.6 kV or 3600 Volts!

here's the simulation without one - notice the voltage at VC - yes that's 3.6 kV or 3600 Volts!

Yes your point?

Of course that is a simulation and you don't know how accurate the components are. I remember when I was about 10 measuring the resistance of a coil, with a hand on each connections to hold the probes in place. When I removed one of the probes but still had one end of the coil and my hand connect I got an almighty belt. That was a lesson the back EMF can be very high. It simply depends on the size of the inductor and how much current you put down. The meter ( an Avo Minor ) only had a single AA battery in it for measuring resistance.

I’ve set the coil resistance to 120R. The simulation is very good. It’s spice and there’s a differential equation you can use to calculate this. Mike this is for all the folks not sure why it’s important... I know you understand.

Basically what happens is that since the source is cut off it spikes up a reverse voltage to try to maintain the current until it’s dissipated. Enough to fry any transistor or your Arduino if it’s connected directly.

And although your particular coils resistance and inductance will vary from device to device this example shows how you can avoid that using a fly back diode. Even with smaller inductors voltages can easily spike up beyond many component ratings.