How to Use the L293D Motor Driver Shield With Arduino
by STEAM-DIY in Circuits > Arduino
66 Views, 1 Favorites, 0 Comments
How to Use the L293D Motor Driver Shield With Arduino
Hello friends, welcome to the SriTu Hobby blog. Today we are going to talk about a motor control topic. today we are going to talk about a more powerful motor driver board.
What is this board?
This board is made as a shield. That is, it’s designed to be connected to the Arduino UNO board. Boards made in this way are called shields. So we can easily use them for our projects. See the pictures below.
This motor driver shield mainly consists of two motor driver ICs and one shift register IC. This shield uses the L293D motor driver IC and 74hc595 shift register IC. We can see two terminals on either side to connect the motors. It can connect two servo motors, four gear motors, and two stepper motors. This motor drive shield can be called a more powerful board. We can see an additional terminal to add extra power to this. For that, remember to provide a voltage lower than 12VDC. Ok, let’s check these motors separately. The required components are given below.
Supplies
- Arduino Uno board x 1
- Motor driver shield x 1
- Servo motor x 1
- Gear motor x 2
- Stepper motor x 1
- Jumper wires x 5(Male to Male)
Servo Motor Test
To do this, connect the components as follows.
Through this shield, we can control two servo motors. For that, we can use D9 and D10 PWM pins. Look at the code below.
- The complete program of this project – Download
The first time we must include the servo library. Use this path for that. Sketch > Include Library > Servo.
After creating a servo object and I’m it’s named “servo1”.This void settings function notifies the library of a PIN we use. The code of this void loop function causes the motor to turn left and right. Click this link for more information on servo motor control. After, we choose the board and the port. Then upload this code.
Gear Motor Test
Connect two gear motors to the motor control shield. But we can control four-gear motors. Connect four-gear motors if you want. To do this, use the circuit diagram below.
Ok, let’s look at the code below.
Complete Program
For that, we first need a library to control the motor shield. Download it using this link. Insert this library into the Arduino IDE using the steps below.
Next, we need to name the two motors we are using and set up the motor control port. I have named M1 and M2.
After, we need to give the motor rotation speed.
Now we can control these motors with the void loop function.
If we want to rotate the motor forward, use “FORWARD” and if we want to rotate the motor backward, use “BACKWARD”. Use the “RELEASE” keyword to stop this motor. Now select the Arduino board and port. After, click the upload button.
Stepper Motor Test
We can control two stepper motors using this motor driver shield. But today we use only one stepper motor. Connect the stepper motor using the circuit diagram below.
Let’s look at the code below.
- The complete program of this project
This also requires the Motor Driver Shield Control Library. We included this library in the previous code. The first time we need to talk to the stepper motor. Use any name for it. I’m named “motor1”. Next, we need to give the step value and motor port.
After, we must set the stepper motor rotation speed.
This void loop code initiates the rotation of the stepper motor.
Next select the board, port, and upload this code to the Arduino board.
Okay, today we discussed three advantages of this motor driver shield. I think you learned that. Please comment below on your issues. Below is the full video of this project. Please watch it and apply this knowledge to your projects. So, we will meet in the next post.
Have a good day.