The Beginner’s Guide to Control Motors by Arduino & L293D

by Electropeak in Circuits > Arduino

1772 Views, 16 Favorites, 0 Comments

The Beginner’s Guide to Control Motors by Arduino & L293D

poster-1.jpg

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 .

Required Materials

component.jpg

Controlling DC Motors

20-1.jpg
11.jpg
circuit-arduino.jpg
22.jpg
21.jpg

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.

Controlling a Stepper Motor

24.jpg
circuit-arduino-stepper.jpg
25.jpg
ezgif.com-video-to-gif-14.gif

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

Controlling a Servo Motor

27.jpg
circuit-arduino-servo.jpg
28.jpg
29.jpg
ezgif.com-video-to-gif-15.gif

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.