Arduino Project 09 - Motorized Pinwheel
In this project you create a circuit to control a motor! The code is minimal (just using a button to control a digital output pin—exactly the same as Project 2), but the circuit introduces a few new components. One is the transistor, and the other is the diode. Again, I want to say that my electrical knowledge is very limited, but I want to give it a shot and explain in my own words what these two components do and why they’re needed for our Arduino to work with a 9-volt DC motor.
The voltage that the Arduino supplies through its pins is only about 3 or 5 volts, and I think also at a much lower amperage than what the motor requires. So, to power the motor, we actually need to use a separate 9 V battery. Instead of our Arduino directly supplying 9 V, we use the Arduino to control a transistor (conceptually, a switch) that manages the supply from the separate power source—the battery. In my head, it’s almost like we have two circuits: one that the Arduino is on, which operates at low voltage, and one that the battery is on, which operates at high voltage. By connecting them via a transistor, their voltages can remain separate, but our lower-voltage circuit can control the higher-voltage one.
This works because a transistor uses some voodoo electrical physics magic to connect two wires by applying a voltage to a third. From what I understand, the voltage used to “switch” the transistor can be totally different from the voltage flowing through the other two wires.
The other component that the circuit introduces is a diode, which acts like a one-way gate for electricity. The book explains that a motor is just copper wire wrapped around a magnet, and while an electric current can make the magnet spin, spinning the magnet can also generate a current. I tested this by hooking the motor directly to an LED, spinning it really fast, and seeing the LED light up.
This property is important to consider, as the motor can potentially become a power source, which could damage components by creating a flow of current in an unexpected, backward direction. The book doesn’t really go into how this would damage the components or what that damage might look like, but it explains that a diode can be used to mitigate the risk.
The book instructs you to connect a diode across the motor’s terminals so that a “one-way gate” is created from the ground wire to the power supply wire. At first, this seems backwards, since this setup wouldn’t allow any current to flow through the diode during normal operation. I still haven’t fully grasped how or why this helps against backward-flowing current, but I think the key takeaway is that you may be safer hooking up a diode to your circuit whenever you’re working with a motor!