I am new to the Arduino but not to programming. The "Getting Started with Arduino" 2ed, 2011, pp69 Figure 5.7 diagrams the use of a Mosfet. I think I understand the mosfet but there is a diode in the diagram that I cannot understand.
9v from the Arduino powers the breadboard's power line. Under Arduino program control, when the mosfet's gate (left leg) is triggered by pin 9, the mosfet drain (middle leg) is connected to the source (right leg). When the Arduino's program powers on pin 9, power would go from the 9v of the Arduino, through the breadboard's power line, to the fan's + wire, through the fan, to the fan's negative wire, to the mosfet's drain (middle leg), through the mosfet, to the mosfet source *right leg) to ground, thereby turning the fan on.
My question is: why is there a diode pointing from the mosfet drain (middle leg) to the breadboard's power line? What is its purpose? There is no explanation in the book. The diode is directional and does not look to be a resistor. I have attached the diagram I found from google (http://manualigratis.altervista.org/it/img51.png) for reference.
Thanks in advance.