I am new to electronics. I am watching this video.
At 4:03, you can see a diode that connects the two pins of the motor:
What role does the diode play?
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It only takes a minute to sign up.Sign up to join this community
This is called a Flyback Diode.
Motors tend to have a large inductance.
Once current gets going in an inductor it doesn't want to stop. If you try to stop it anyway by cutting off the current path the voltage will spike to a very high level and probably damage something (the mosfet in this case).
The diode gives the current somewhere to go. It routes it back to the other side of the inductor and allows the current to flow in a loop until it dies down due resistive losses.
The diode is sometimes also called a Freewheeling Diode for this reason.