Electronic – arduino – In this transistor circuit, what is the purpose of the diode across the motor


I am trying to follow an Audrino tutorial with my kid and I am confused by the role of the diode in this circuit.

In particular, I have the following questions:

  1. It looks like the circuit will work without the diode. The purpose seems to be to allow the current flow from the pin9 power source, but why do we need that?
  2. Does current flow from pin 9 through the emitter to the ground?
  3. More generally, when someone says “the current” is in this direction, do they mean that is the + => – direction, or the flow of the electrons?

enter image description here

Best Answer

  1. The diode in this configuration is called a "flyback" diode. A motor consists of a coil of wire which is effectively an inductor (and an electromagnet). As the motor spins, the coil will be turned on and off with the commutator inside the motor which will cause voltage spikes. The diode provides a path for this energy so that it can be dissipated into the +5V rail rather than going somewhere else less predictable. You'll also find these diodes across relay coils. Usually you'll also put a capacitor on the 5V rail to further absorb the spikes (otherwise you'll get noise everywhere). NOTE: Your question says "Pin 9 power source". That is incorrect, see the next question.

  2. Yes, but not very much current. That's the purpose of this circuit. Very little current (uA or mA) can be used to control a motor (~200mA with that transistor from +5V through the motor). Only about 330uA (closer probably to 270uA...I haven't typed any numbers into a calculator) will flow from Pin 9 into ground through the transistor. The current for the motor comes from the +5V rail.

  3. That is correct. When talking to someone, current always flows from high potential (+) to low potential (-), even though the electrons are going the opposite direction. Really it's just a convention so that all the signs work out.