The Arduino® microcontroller can be used to control several different types of motors. Though the exact electronic control circuit will vary depending on the project, every motor is linked to an output pin on the Arduino® board. Programming code can be used to change the speed and direction of a connected motor, or to advance a motor to a chosen position. The three most common varieties of Arduino® motors are direct current (DC), stepper, and servo.
A direct current motor is relatively simple, and can be used for many purposes. DC motors contain coils of wire that are placed within a magnet. When electricity is sent through the coils, the resulting electromagnetic field causes a shaft to rotate. Many of the direct current Arduino® motors that are used in these projects include simple gearboxes, which provide leverage for turning heavy wheels or accomplishing other mechanical tasks.
Very small DC motors can be directly connected to an Arduino® output pin, but motors that draw more than 40 milliamps of current require additional control circuitry. Transistors are often used for this purpose.; this allows the Arduino® to use a low-current signal, which activates a solid-state switch and sends high-current power to the motor. In some applications such as robotics, several transistors are combined in an arrangement known as an “H-bridge.” An H-bridge allows the electrical polarity to be reversed, and enables DC Arduino® motors to be driven forward or backward.
Arduino® stepper motors are similar to DC motors, but do not rotate continuously. Instead, the internal arrangement of electromagnetic coils makes a stepper motor advance or “step” forward in small increments. As an example of this movement, the hands of a battery-powered analog clock are often driven by a stepper motor. Arduino® motors with an attached stepper motor must be programmed to output a series of pulses. Each signal causes the motor to “step” one time.
Servo motors are significantly different from either DC or stepper motors. This motor has integrated gears and circuitry for controlling the shaft position very accurately. These types of Arduino® motors are usually not intended for complete circular rotation, but instead move within a 90° or 180° range. Servo motors require both a constant power source and a position signal, which determines the exact position of the shaft. Servos, as these motors are often called, can often move from position to position with great speed and accuracy.