Motors guide series
Direct current motor
Direct current motors represent the easiest way to add movement to your projects. A direct current or DC motor can be a very cost effective and flexible solution for all sorts of projects: robots, cars, boats, toy helicopters, home automation, and many more.
In this article, you will learn how to use a DC motor through a series of three projects.
Here's the project outcomes:
- Project 1: connect the motors to the Arduino via the motor driver module, and make them spin in a single direction.
- Project 2: use a potentiometer to control the direction of rotation and speed of the motors.
- Project 3: use an ultrasonic sensor to control the rotational speed the motors.
Before we get into the projects, I want do a quick introduction to motors, and specifically to discuss the kinds of motors you can use in your projects.
Types of motors
The most common type of motor is the DC (Direct Current) motor. DC motors are low cost devices that work by connecting two wires to positive and negative voltage. Once you connect them to power, the rotor will turn. The direction of the rotor spin depends on the polarity of the connection. To reverse the direction of the spin, just switch the electrical connections.
All electrical motors work by taking advantage of the forces generated by a magnet (permanent or temporary electromagnet) and the electric field generated by electrical current as it travels through a coil. (Here is the source of the schematic below).
The DC motor can spin very quickly, which often is not what we want in our applications. For example, if you are building mechanism that opens the shutters of a window, you would like the shutter to open slowly to avoid damaging it. A DC motor on its own would try to get to full speed immediately. So, in most cases people attach a gear box to the motor. The gear box will convert high rotational spin from the shaft of the motor to lower rotational speed but higher torque so that large loads can be moved.
Another common type of motor is the stepper motor.
A stepper motor operates by moving the motor rotor in steps, hence the name. I have written a dedicated article on stepper motors.
While the DC motor will move continuously as long as there is power, a stepper motor will move by one step when an appropriate signal is send via a wire, and then stop. Additional signals are needed for the rotor to move further. The size of each step (measured in degrees) depends on the mechanical characteristics of the motor as well as the characteristics of the electronic signals it receives on its coils.
For applications where you need fine control and small movements, a stepper motor is a good choice. For example, they are used in 3-D printers, where milli-meter accuracy is needed.
Stepper motors tend to be bulkier and more expensive then DC motors. They contain multiple coils and more complicated mechanical components, and that is reflected in their cost. The electronics needed to control stepper motors are also more complicated compared to DC motor controllers.
A common problem with stepper motors is that in certain situations (usually under high load), there is a mismatch between the signal that the motor controller is sending and the actual mechanical movement that the motor produces. In simple words, the rotor may “miss” steps and the controller will never know because usually there is no feedback mechanism to track and confirm movement.
A servo motor is designed to remedy this problem. A servo motor contains a DC motor, a gear box, and a position feedback mechanism. This mechanism can convert a simple DC motor into an a motor that can achieve precision movement with the ability to report its position to its controller circuit. Servo motors are used extensively in robotics, manufacturing automation systems, and high-end toys.
Now that you have a better understanding of motors, time to roll up your sleves and work on Project 1.
If you would like to learn how to use DC motors with your Arduino, consider enrolling to Arduino Step by Step Getting Serious.
We have a full section (Section 16) with 10 lectures dedicated to this topic.
New to the Arduino?
Arduino Step by Step Getting Started is our most popular course for beginners.
This course is packed with high-quality video, mini-projects, and everything you need to learn Arduino from the ground up. We'll help you get started and at every step with top-notch instruction and our super-helpful course discussion space.
Jump to another article
2. How to drive a DC motor without a motor driver module
3. What is "microstepping"?
4. Direct current motor
5. Project 1: Control two DC motors with your Arduino and the L298N controller
6. Project 2: Control speed and direction with a potentiometer
7. Project 3: DC motor control with a distance sensor
8. Project 1: Control a servo motor with a potentiometer
9. Project 2: Servo motor control with VarSpeedServo
Done with the basics? Looking for more advanced topics?
Arduino Step by Step Getting Serious is our comprehensive Arduino course for people ready to go to the next level.
Learn about Wi-Fi, BLE and radio, motors (servo, DC and stepper motors with various controllers), LCD, OLED and TFT screens with buttons and touch interfaces, control large loads like relays and lights, and much much MUCH more.