Motors are devices that allow us to transfer electricity into humanly perceptible physical motion of objects. There are several types of motors:
For a servo example see the bottom of the Analog Page or the ITP Servo Lab . For stepper examples see the ITP Stepper Motor Lab. This lab will work with controlling DC motors (although you could also use a solenoid)
Transistors & MOSFETs
In order to run properly most motors will require much more amperage and / or voltage than the arduino is capable of outputting. So in order to properly run a motor, we are going to need an extra power supply that can power the motor. This extra power supply can be:
a 9 volt battery
a power brick
or a bench top power supply.
If we want to interface our low power microcontroller (Arduino) with a higher power supply, and thus a hight power output like a motor, we will need to learn how to use transistors.
Transistors are a type of electrical switch where you can use a low power signal (like the output of one of your arduino’s digital pins) to enable or disable flow of a higher current or voltage to components like motors or high wattage LED which would require more current and voltage than the arduino is capable of providing on its own.
There are 2 type of transistor NPN and PNP. In this lab we will be using an NPN transistor. You can use either the 2N3904 or TIP 120.
The schematic view looks like this for all NPN transistors:
Pinout follows as so:
Warning: Be sure to read the numbers on your parts in order to identify them. There are many other types of components that look identical to these transistors and the only way to distinguish between them is by the numbers on their faces.
Warning: Be sure to identify the front and the back of the component to avoid backwards wiring.
For these transistors we want to make sure our control voltage (The Arduino) is connected to the Base (B), and that your Emitter (E) is connected to Ground (GND).
The Collector (C) will be connected to our motor and positive lead of the power supply. Make sure the power supply is also connected to the same ground as the Arduino
MOSFETS are similar in physical shape and functionality to transistors and can be used in this lab. We can use an IRF520 in place of our TIP120 or 2N3904. Internally MOSFETS work slightly differently and their schematics and pinouts will refer to a Gate, Drain, and Source. For our lab we can equate the pins of a transistor to those of a MOSFET as listed below:
IRF520 Pinout and schematic
Inductance is a physical property of conductors in which:
- In which a steady electrical current creates a steady magnetic field
—– and —–
- A moving magnetic field can induce an electrical current
This property is what allows us to make and use motors in our tools, clocks, cars, and appliances. It is also one of the ways that we can generate electricity with the use of kinetic mechanisms (physical mechanical motion) and strong magnets. For example car alternators, bicycle powered battery chargers, and wind turbines.
For us, this means we must always be aware of back voltage.
Because cutting the power to a motor will not automatically stop its internal mechanical parts from moving, we need to add some protective circuitry, just in case your motor happens to induce an unwanted electrical current . Cue our friend the Power Diode:
Diodes are polarized components that allow electrical current to flow in one direction, from anode to cathode, and block any current that may try to flow opposite that direction. In the case of power diodes, the cathode side is usually marked with stripe (grey strip in the above case). Sound familiar?
Putting it all together
Now with all this information and our protective diodes we can wire up our Arduino, Transistor, Diodes, and DC Motor