A motor is an electrical machine that converts electrical energy into mechanical and allows you to perform automated tasks, such as rotating the blades of a fan, employing that electric current. Incorporating motors in Arduino projects is a widespread practice because it opens doors to many new possibilities.
But, can Arduino power a motor? No, you cannot directly power a motor through an Arduino board because Arduino can produce a maximum current of 40 mA, whereas a motor requires much more current to run.
However, there are options to power a motor with Arduino, such as using a set of DC batteries. So, you can indirectly power a motor using Arduino under certain circumstances, which I’ll cover in this article and show you how Arduino can power a motor.
How Does a Motor Work?
Motors convert electrical energy into mechanical. Inside the motor, there’s a coil between two poles of a magnet, and a voltage is applied on the opposite ends of the coil. The current flows through the coil generating a force and making it rotate clock- or anticlockwise depending on the voltage’s polarity.
This phenomenon happens because of Faraday’s law of electromagnetic induction, which states that a current-carrying conductor will experience a force when placed inside a magnetic field.
But, let’s not get into the minute details of the working principle of motors!
All you need to know is that if you attach the two ends of a DC motor to a battery, it will start rotating, and if you reverse the polarity, it will turn in the opposite direction.
In simpler words, a simple reversal of polarity changes the direction in which a motor rotates.
What Types of Motors are There?
There are many kinds of motors, but you can use only some of them in Arduino projects. The most popular ones are DC, servo, and stepper motors.
These motors are the simplest ones since they have only two terminals – ground and power, while servo motors and stepper motors are a bit complex.
Servo motors have a control circuitry, a gearbox, and a potentiometer. In addition to a DC motor that allows precise control over the motor, these components also allow the motor to work in a closed loop with the microcontroller.
Stepper motors, as its name said, work in “steps” and provide greater control over the movement of the motors.
How to Power a Motor Using Arduino?
A common misconception about 5V DC motors is that Arduino can Power them directly because the board can provide a voltage of 5 volts.
But doing so can destroy the Arduino board because a motor draws much more current than a regular Arduino board can supply. Therefore, it’s not possible to directly connect a motor with the pins of an Arduino board.
Then, how can you run motors in Arduino projects? You can use motor drivers to run and control motors in Arduino projects.
Using Motor Drivers
What’s a motor driver? As the name suggests, motor drivers “drive” a motor by connecting it with Arduino since one cannot connect them directly to the board.
There are many different kinds of motor drivers available in the market. Each one of them offers a different set of features that are used to power various motors. “One size fits all” does not apply for motor drivers because each type of motor works differently; hence they need different drivers.
Let’s take a look at the most common types of motor drivers.
H-Bridge Motor Driver
An H-bridge is a motor driver circuit made of four transistors working as switches, arranged in a way that the circuit looks like an “H” when viewed from above. The circuit controls the motor’s rotations – either forward or backward, depending on the current’s direction.
Each pair of transistors connect the motor’s opposite ends, and one is supplied with the input voltage while the other transistor is grounded.
In the case of positive polarity, one pair of transistors switch on at a time, the current flows from the source voltage to the positive terminal of the motor, then to the negative terminal of the motor, and finally to the ground.
Similarly, in the case of negative polarity, the current flows from the voltage source to the negative terminal of the motor, then to the positive terminal, and finally to the ground.
If you wish to sharpen a bit more your knowledge about the H-bridge circuit, check out this article.
Motor Driver ICs
A very convenient option to drive motors in Arduino projects is to use motor driver ICs. You don’t need to build a complicated circuit for this, all that’s needed is a compact IC to control a motor through Arduino.
The most popular ICs are A4988, DRV8833, L293, and ULN2003. But, which one should you use in your next motor project?
Well, to select the right motor driver IC, you’ll have to consider the type of motor you’ll use. Furthermore, the current and voltage requirements must also be kept in mind when making this decision.
Here’s a detailed guide on choosing the right motor driver for your Arduino project.
What’s the PWM Motor Control?
Pulse Width Modulation (PWM) is a useful tool that allows you to control the time for which a voltage level is high.
If you picture a square wave, you’ll notice that the time for which the pulse is at a high state is equal to the time for which it’s at a low state. But if you tamper this pulse in such a way that the on-time is more than the off time or vice versa, then this is known as pulse width modulation.
A pulse width modulation allows you to vary the power supplied to the motor at different time instances, which in turn changes the motor’s speed.
For instance, if you wish to vary the speed of a fan using Arduino, then you’d need to use the PWM technique to achieve such a task.
There’re a few PWM pins present on every Arduino board, marked with a small sine wave. If you have an Arduino UNO board, you’ll notice this mark on the digital pins 3, 5, 6, 9, 10, and 11.
Using these pins, you can generate a PWM pulse for your motor.
Motor’s Applications in Arduino Projects
The use of motors in Arduino projects opens doors to multiple possibilities, where you can make different robotics and home automation projects.
Here’s a list of exciting Arduino motor projects that you might want to try:
- Line following robot
- Obstacle avoiding robot
- Wireless fan speed controller
- Touchless trash can
- Hand sanitizer dispenser
- Rubik cube solver
- Robotic arm
- 3D printer
- Automatic pet feeder
If you want to check out more Arduino projects that use motors, check this article here.
Now that you know how Arduinos can power a motor, you are ready to work on your upcoming motor-based project.
Always make sure not to connect the motor with your Arduino board directly, but use the techniques discussed in this article to integrate them in your next Arduino projects.
Feel like deep down a bit more on this subject? Check out these articles:
- How To Control a DC Motor with an Arduino (allaboutcircuits.com).
- Arduino – DC Motor (tutorialspoint.com).
- Arduino DC Motor Control Tutorial – L298N | PWM | H-Bridge (howtomechatronics.com).