Arduino L293D Motor Driver Protect Tutorial

You’ll be able to learn this and plenty of different superb tutorials on ElectroPeak’s official web site


On this tutorial, you’ll discover ways to drive DC, stepper and servo motors utilizing an Arduino L293D motor driver protect.

What You Will Be taught:

  • Normal details about DC motors
  • Introduction to L293D motor protect
  • Driving DC, Servo & Stepper motors

Step 1: Motors & Drivers

Motors are an inseparable a part of many robotics and electronics tasks and have differing kinds you should utilize relying on their software. Right here is a few details about various kinds of the motors:

DC Motors: DC motor is the most typical sort of engine that can be utilized for a lot of functions. We will see it in distant management vehicles, robots, and and many others. This motor has a easy construction. It would begin rolling by making use of correct voltage to its ends and alter its route by switching voltage polarity. DC motors velocity is straight managed by the utilized voltage. When The voltage degree is lower than the utmost tolerable voltage, the velocity would lower.

Stepper Motors: In some tasks akin to 3D printers, scanners and CNC machines we have to know motor spin steps precisely. In these circumstances, we use Stepper motors. Stepper motor is an electrical motor that divides a full rotation into numerous equal steps. The quantity of rotation per step is decided by the motor construction. These motors have a really excessive accuracy.

Servo Motors: Servo motor is an easy DC motor with a place management service. By utilizing a servo it is possible for you to to regulate the quantity of shafts rotation and transfer it to a selected place. They normally have a small dimension and are your best option for robotic arms.

However we are able to’t join these motors to microcontrollers or controller board akin to Arduino straight so as to management them since they probably want extra present than a microcontroller can drive so we want drivers. The driving force is an interface circuit between the motor and controlling unit to facilitate driving. Drives are available many differing kinds. On this instruction, you be taught to work on the L293D motor protect.

L293D protect is a driver board primarily based on L293 IC, which might drive four DC motors and a couple of stepper or Servo motors on the similar time.

Every channel of this module has the utmost present of 1.2A and doesn’t work if the voltage is greater than 25v or lower than four.5v. So watch out with choosing the right motor based on its nominal voltage and present. For extra options of this protect let’s point out compatibility with Arduini UNO and MEGA, electromagnetic and thermal safety of motor and disconnecting circuit in case of unconventional voltage elevate.

Step 2: The way to Use Arduino L293D Motor Driver Protect?

Whereas utilizing this protect 6 analog Pins (which can be utilized as digital pins too), pin 2 and pin 13 of arduino are free.

Within the case of utilizing Servo motor, pins 9, 10, 2 are in use.

Within the case of utilizing DC motor, pin11 for #1, pin3 for #2, pin5 for #three, pin6 for #four and pins four, 7, eight and 12 for all of them are in use.

Within the case of utilizing Stepper motor, pins 11 and three for #1, pins 5 and 6 for #2 and pins four, 7, eight and 12 for all of them are in use.

You should utilize free pins by wired connections.

If you’re making use of separate energy provide to Arduino and protect, be sure to have disconnected the jumper on the protect.

Step three: Driving DC Motor


The Library you should management the motor:

AF_DCMotor motor(1, MOTOR12_64KHZ)

Defining the DC motor you might be utilizing.

The primary argument stands for the variety of the motors within the protect and the second stands for the motor velocity management frequency. The second argument may be MOTOR12_2KHZ, MOTOR12_8KHZ, MOTOR12_8KHZ, and MOTOR12_8KHZ for motors #1 and a couple of, and it may be MOTOR12_8KHZ, MOTOR12_8KHZ, and MOTOR12_8KHZ for motors quantity three and four. And if it left unchecked, it is going to be 1KHZ by default.


Defining the motor velocity. It may be set from zero to 255.

void loop()

Perform specifies the motor’s movement standing. The standing may be FORWARD, BACKWARD, and RELEASE. RELEASE is similar because the brake however it might take a while till the motor’s full cease.

It is suggested to solder a 100nF capacitor to every motor pins to cut back noise.

Step four: Driving Servo Motor

Arduino IDE library and examples are appropriate for driving a Servo motor.


The library you want for driving the Servo motor

Servo myservo;

Defining a Servo motor object.

void setup()

Decide the pin connecting to Servo.(pin 9 for sevo #1 and pin 10 for servo #2)

void loop()

Decide the quantity of motor rotation. Between zero to 360 or zero to 180 based on motor sort.

Step 5: Driving Stepper Motor

#embrace <AFMotor.h>

Decide the library you want

AF_Stepper motor(48, 2);

Defining a Stepper motor object. The primary argument is the motor step decision. (for instance, in case your motor has the precision of seven.5 deg/step, it means the motor step decision is . The second argument is the variety of the Stepper motor related to the protect.

void setup()

void loop()

Decide motor velocity in rpm.

The primary argument is the quantity of step wanted to maneuver, the second is to find out route (FORWARD or BACKWARD), and the third argument determines the steps sort: SINGLE (Activate a coil), DOUBLE (Activate two coils for extra torque), INTERLEAVED (Steady change within the variety of coils from one to 2 and vice versa to double precision, nonetheless, on this case, the velocity is halved), and MICROSTEP (Altering the steps is finished slowly for extra precision. On this case, the torque is decrease).By default, when the motor stops transferring, it maintains its standing.

You could use the perform motor.launch() to launch the motor.

Step 6: Purchase Arduino L293D Motor Driver Protect

Step 7: Associated Tasks:

Step eight: Like Us on FaceBook

If you happen to discover this tutorial useful and attention-grabbing please like us on fb.



    Leave a Reply

    This site uses Akismet to reduce spam. Learn how your comment data is processed.