L293D Motor Driver - Arduino Module

by antorobotix in Circuits > Arduino

44 Views, 0 Favorites, 0 Comments

L293D Motor Driver - Arduino Module

Immagine WhatsApp 2024-12-29 ore 21.33.04_5a9dbd4a.jpg
Immagine WhatsApp 2024-12-29 ore 21.37.33_69c946df.jpg

Hi I'm Antonio, a 14 years old into elecronics. I've developed a simple circuit board you can use to control the speed and direction of a low-courrent rated motor ussing the L293D motor driver.


A motor driver is an integrated circuit used to control motors in electronics applications. It acts as an interface between a microcontroller (like an Arduino) and the motors, controlling their speed and direction. The most common and popular IC's are from the L293 series, such as L293B, L293D, L293NE, etc. These IC's are designed to control 2 DC motors simultaneously. We will be speaking off the L293D IC only. The L293D has 16 pins and consists of two H-bridge. An H-bridge is the simplest circuit for controlling a low-current rated motor.

Supplies

pin configuratio L293d.jpg
Immagine WhatsApp 2024-12-29 ore 18.24.20_2b654170.jpg
  1. Perf Board (or any type of project board)
  2. L293D IC
  3. 16-pin IC socket
  4. 4x 1uF capacitors
  5. 1x 1uf capacitor
  6. 4x 220Ω
  7. 2x 5mm 3V LED
  8. 8x header female pins
  9. 3x 2 pins screw connector
  10. Arduino (Any) to test the Driver
  11. Computer with Arduino IDE installed
  12. Various items: soldering iron, solder, wires (both solid and flexible), pliers, etc.

Circuit Design

L293D schema 3.png

How the circuit works


besides being a simple circuit, it took a long time to design and test it, so I created a schematic to explain how it works.

  1. Enable 1 is connected to a pin of ypou arduino wich can output a PWM signal. By changing the value of this signal you can chose the sspeed of the first motor, if don't want control the speed, just pull this pin HIGH.


  1. Input 1 and Input 2 are connected to a digital pin of your arduino.By setting one HIGH and the other on LOW the motor will turn in one direction, if do the same thing by reversing the signal (swapping HIGH and LOW) the motor will turn in the opposite direction.


  1. Outpt 1 and Outpu 2 are connected to the pins of the first motor passing through capacitors, used to filter high frequencis and courrent spike protecting the IC.


  1. The 4 GND pins are not only used to connect the IC to GND but also to dissipate the heat that produces, due to the high courrent that passes throgh it.


  1. The VS pin is used to is used to provide power to the motors connected to the driver.


  1. The VSS pin is used to supply the logic voltage which powers the chip's internal logic.


  1. Enable 2, Input 3 and Input 4, Output 3 and Output 4 work the same way as Enable 1, Input 1 and 2, Output 1 and 2 do.


  1. The two LEDs are used to check if the Arduino is correctly sending inputs to the L293D. The first one is connected to Input 1 and 2 and the other one is connected to Input 3 and 4. Every onre of these inputs is connected to the LED passing through a resistor of 220Ω.

Testing and Assembling

Immagine WhatsApp 2024-12-29 ore 19.46.34_95af5ed4.jpg
Immagine WhatsApp 2024-12-29 ore 21.37.33_628fa600.jpg
Immagine WhatsApp 2024-12-29 ore 19.57.45_278bd678.jpg

Before placing all the components on to the board, I highly recomment to test all your components and entire circuit on a breadboard and check the datasheet of your motor driver.

Once you have done this, you can proceed by placing all the components on your board and start connecting them however you want! I've done this making traces with solder on the bottom side of the board and on the top side I've bent into shape some solid core wires and placed them as needed and it ended up resulting in a very cool design.

If you want you can check the connections and wash the board with some isopropyl alcohol to remove all the excess flux and solder.

Arduino Code for Testing

Here is some code I wrote that you can use to test your driver module. Feel free to modify it however yoy want!

For another code source and schematic check the L293D Motor Driver by Ani24


// Motor A pins

int enableA = 2; // Enable pin for Motor A

int MotorA1 = 4; // Input 1 for Motor A

int MotorA2 = 5; // Input 2 for Motor A


// Motor B pins

int enableB = 3; // Enable pin for Motor B

int MotorB1 = 6; // Input 1 for Motor B

int MotorB2 = 7; // Input 2 for Motor B


void setup() {

// Set Motor A control pins as outputs

pinMode(enableA, OUTPUT);

pinMode(MotorA1, OUTPUT);

pinMode(MotorA2, OUTPUT);


// Set Motor B control pins as outputs

pinMode(enableB, OUTPUT);

pinMode(MotorB1, OUTPUT);

pinMode(MotorB2, OUTPUT);


// Enable both motors

digitalWrite(enableA, HIGH);

digitalWrite(enableB, HIGH);

}


void loop() {

// Spin Motor A forward and Motor B backward

digitalWrite(MotorA1, HIGH); // Motor A forward

digitalWrite(MotorA2, LOW);

digitalWrite(MotorB1, LOW); // Motor B backward

digitalWrite(MotorB2, HIGH);


delay(2000); // Run for 2 seconds


// Stop both motors

digitalWrite(MotorA1, LOW);

digitalWrite(MotorA2, LOW);

digitalWrite(MotorB1, LOW);

digitalWrite(MotorB2, LOW);


delay(1000); // Pause for 1 second


// Reverse directions: Motor A backward, Motor B forward

digitalWrite(MotorA1, LOW); // Motor A backward

digitalWrite(MotorA2, HIGH);

digitalWrite(MotorB1, HIGH); // Motor B forward

digitalWrite(MotorB2, LOW);


delay(2000); // Run for 2 seconds


// Stop both motors again

digitalWrite(MotorA1, LOW);

digitalWrite(MotorA2, LOW);

digitalWrite(MotorB1, LOW);

digitalWrite(MotorB2, LOW);


delay(1000); // Pause for 1 second before repeating

}