# Understanding This Arduino Circuit

I'm really new to electronics and I'm working through the Arduino starter kit.

With this example, I'm having trouble understanding the flow of electricity and a few other things. Here are my questions:

1. It looks like the motor is receiving two positive sources of voltage: one coming from pin 9 after it goes through the transistor-- then another coming out of the 9v battery, down the power rail, and into the motor. Why is the power from the 9v battery necessary? I thought the transistor's purpose was to modify the electrical current so that it was capable of operating the motor. Further, if the 9v battery is connected to the motor, why is that in itself not spinning the motor?
2. I don't understand how everything's flowing back to the leftmost ground rail. From the perspective of the motor, one wire is attached to the positive lead of the 9v battery and the other wire is attached to the gate coming out of the transistor. How is this thing grounded?
3. The positioning of the diode throws me off even further. My understanding was that their purpose in a circuit like that was to prevent electricity from flowing back into the circuit from components like motors, but in this circuit, it doesn't seem to be positioned between the motor and the rest of the circuit like I'd expect.

• @Andyaka I think the author doesn't know how to lay out a proper schematic. He's admitted he doesn't understand current. Probably just reading through tutorials that have pictures of wiring. – jonk Sep 30 '16 at 18:51
• I didn't draw this schematic. This is from the book. – kwikness Sep 30 '16 at 19:07
• @kwikness This is NOT schematic! As Andy aka said - it's a cartoon. – Jakub Rakus Sep 30 '16 at 19:35
• Yes, it is a fancy picture so please do not learn from your book that these are schematics. – Bence Kaulics Sep 30 '16 at 21:17

1. It looks like the motor is receiving two positive sources of voltage: one coming from pin 9 after it goes through the transistor-- then another coming out of the 9v battery, down the power rail, and into the motor.

Pin 9 provides a signal, not power. And the signal is applied to a NMOS transistor gate. (Or, at least, I think so if the circuit works okay. I can't be sure, because your picture doesn't specify the exact device involved and they can be packaged differently.)

I think this signal is a gate voltage. It doesn't directly connect to the motor. Instead, it signals NMOS transistor to connect the other two pins it possesses together.

1. Why is the power from the 9v battery necessary?

You'd mistakenly believed that Pin 9 provides a voltage to the motor. But it doesn't. So the motor needs access to a low impedance voltage source, which in this case is your $9\:\textrm{V}$ battery. Note that I said "low impedance." The $5\:\textrm{V}$ power supply for your Arduino is also low impedance and it could have been used, too. (Depending on the motor and whether or not it really needs the full $9\:\textrm{V}$ to operate well.) But you could not have used Pin 9, which is not a very good voltage source and couldn't run the motor on its own. Pin 9 can signal with voltages. And with very low power devices, like LEDs, it can power them, too. But it cannot drive motors. It just doesn't have the capacity to handle that. So, instead, Pin 9 is used to signal an NMOS device to do the work.

1. I thought the transistor's purpose was to modify the electrical current so that it was capable of operating the motor.

This transistor is operating like a switch. And just in case you were imagining differently, a transistor cannot create current out of thin air. A power supply provides the current compliance.

1. Further, if the 9v battery is connected to the motor, why is that in itself not spinning the motor?

It is.

1. I don't understand how everything's flowing back to the leftmost ground rail. From the perspective of the motor, one wire is attached to the positive lead of the 9v battery and the other wire is attached to the gate coming out of the transistor. How is this thing grounded?

The $9\:\textrm{V}$ battery doesn't need to go through the leftmost ground rail. There is a bottom horizontal wire in the image which connects the (-) of the $9\:\textrm{V}$ battery to the (-) of the Arduino power supply. But that is there to set up a galvanic reference against which the NMOS gate is then driven. This allows the otherwise single-ended Arduino output on Pin 9 to do its job.

1. The positioning of the diode throws me off even further. My understanding was that their purpose in a circuit like that was to prevent electricity from flowing back into the circuit from components like motors, but in this circuit, it doesn't seem to be positioned between the motor and the rest of the circuit like I'd expect.

It is arranged parallel across the motor, opposite to the polarity of the $9\:\textrm{V}$ battery (otherwise, it would conduct when the battery voltage was applied.) It's there to allow accumulated energy (evidenced as current) in the motor, when turned off, to have a galvanic path to move through and to allow the magnetic field to discharge its energy in a managed way.

I think the circuit looks like this:

simulate this circuit – Schematic created using CircuitLab

Software must be monitoring the switch and then driving the NMOS switch to operate the motor. Perhaps you can slightly better see that a shared ground would be required in order to operate the NMOS switch's gate.

While I don't know the exact setup, it appears your circuit is like this:

simulate this circuit – Schematic created using CircuitLab

The FET is acting as an electronic switch controlled by the Arduino. When the output line from the Arduino is high, the FET is switched on and provides a path from the negative terminal of the motor back to ground. When the line is low, the FET is off and is basically an open circuit so there is no return path for the current. The diode is there so that the voltage doesn't spike when the motor is turned off.

• Yup. That's about what I saw there. (It picks off of an Arduino header with a silk-screened "~9" on it, though.) That, and the pulled-down switch (using a 10k, I think, from the picture) going to "2" on header. – jonk Sep 30 '16 at 18:39
• Nope, that's not enough, what about the ground wire between the Arduino and the FET source? – Neil_UK Sep 30 '16 at 18:40
• @Neil_UK Yes, there IS and needs to be a shared ground. Chris needs to add that in order to get things squared away. – jonk Sep 30 '16 at 18:49
• Obviously the Arduino is not going to run without both power and ground connected, but I was trying to simplify things as much as possible. The button in the picture is also not in my diagram because it doesn't add anything to kwikness' question. – Chris Ryding Sep 30 '16 at 19:53
• @ChrisRyding the ground I refer to is not about 'running' the Arduino, but about being a reference voltage for the gate drive. At the moment, the voltage on the FET gate depends on whether the 9v battery is being held by someone who has just walked over a nylon carpet. – Neil_UK Sep 30 '16 at 20:24