Introduction: The Beginner’s Guide to Control Motors by Arduino & L293D
In this article, you will learn how to control DC, Stepper, and servo motors by Arduino and L293D. At the end of this tutorial, you should be able to control spinning direction, acceleration, speed, power and shaft position.
If you do not know what L293D is, we suggest reading L293D: Theory, Diagram, Simulation & Pinout .
Step 1: Required Materials
Step 2: Controlling DC Motors
There are several types of DC motors, but here we will use a simple brushed DC motor. It has small plastic gears and is quite easy to drive. This motor is suitable for small robots and toys.
In this circuit, the adjustable Power supply can be replaced with a 9V battery or power adapter. Make sure all wires and cables are connected correctly and then upload the code.
This is a very simple code. You can add more lines of code to improve motor performance.
Attachments
Step 3: Controlling a Stepper Motor
In this project we use a four-wire stepper motor. You can control stepper motors in three modes. Single step, half step, and power step. You should know the stepper motor wiring connections. If you don’t, use an ohm meter to find out.
Sometimes, Stepper motors make some noise in the circuit. You can parallel a few capacitors to remove them.
This code is just for first time running. To improve the performance of motor, you can use the example code of Arduino libraries
Step 4: Controlling a Servo Motor
Micro servo motors (also known as 9 grams servo) are very useful in small robotics projects like a robot arms. You should produce PWM signals to control servo motors. Servo motors can be very fast and powerful based on their type and size.