Control 2 Motors With the L293DNE Dual Motor Driver IC and Arduino 101

by TechMartian in Circuits > Electronics

7410 Views, 2 Favorites, 0 Comments

Control 2 Motors With the L293DNE Dual Motor Driver IC and Arduino 101

0h+WoyZ1Tz+bw0zYzMYrNQ_thumb_76e.jpg
Dual Motor Driver with L293DNE

This is a dual motor driver board using the L293DNE IC which is a quadruple half-H-bridge. It is used to run two motors at variable speeds controlled by the Arduino 101.

Materials and Tools

IMG_1871.JPG

  • Arduino
  • 2x DC Motor
  • L239DNE IC
  • Breadboard wires
  • 6x Jumper Wires
  • Breadboard

Connecting the VCC Pins

cAwgIFcmT8y2%+y9+LyX1A_thumb_769.jpg

Connect pins 1, 8, 9, 16 of the L293DNE IC all to 5V from the Arduino.

Connecting the Ground Pins

78sekKRPQaONxlOyixblUA_thumb_76a.jpg

Connect pins 4, 5, 12, 13 of the L293DNE IC to ground.

Connecting the Signal Pins

zRsPF5HzRJSinZesyC7nAA_thumb_76b.jpg
kv6aB+rmQr6f5iq5QFkLEg_thumb_76c.jpg

Connect the following IC pins to the Arduino with the jumper wire colour in the images serving as a guide.

L239DNE PinArduino PinJumper Wire Colour
9D3Green
6D5Brown
5D6Blue
3D9Red

Connecting the DC Motors

3QuR%0fZRB2n06TxsxBllA_thumb_76d.jpg

Connect the two leads of one DC motor to pins 3 and 6 of the L293DNE IC. And connect the second DC motor pins to pins 11 and 14 of the L293DNE IC.

Coding and Uploading

Screen Shot 2017-08-19 at 12.08.43 AM.png

Select the appropriate board under tools and it's corresponding port once connected. Then, upload the following code to the board.

//Motor A
const int motorPin1  = 3;  // Pin 14 of L293
const int motorPin2  = 5;  // Pin 10 of L293
//Motor B
const int motorPin3  = 6; // Pin  7 of L293
const int motorPin4  = 9;  // Pin  2 of L293
//This will run only one time.
void setup(){
 
    //Set pins as outputs
    pinMode(motorPin1, OUTPUT);
    pinMode(motorPin2, OUTPUT);
    pinMode(motorPin3, OUTPUT);
    pinMode(motorPin4, OUTPUT);
    
    //Motor Control - Motor A: motorPin1,motorpin2 & Motor B: motorpin3,motorpin4
   
}
void loop(){
  
 //This code  will turn Motor A clockwise for 2 sec.
    digitalWrite(motorPin1, HIGH);
    digitalWrite(motorPin2, LOW);
    digitalWrite(motorPin3, LOW);
    digitalWrite(motorPin4, LOW);
    delay(2000); 
    //This code will turn Motor A counter-clockwise for 2 sec.
    digitalWrite(motorPin1, LOW);
    digitalWrite(motorPin2, HIGH);
    digitalWrite(motorPin3, LOW);
    digitalWrite(motorPin4, LOW);
    delay(2000);
    
    //This code will turn Motor B clockwise for 2 sec.
    digitalWrite(motorPin1, LOW);
    digitalWrite(motorPin2, LOW);
    digitalWrite(motorPin3, HIGH);
    digitalWrite(motorPin4, LOW);
    delay(2000); 
    //This code will turn Motor B counter-clockwise for 2 sec.
    digitalWrite(motorPin1, LOW);
    digitalWrite(motorPin2, LOW);
    digitalWrite(motorPin3, LOW);
    digitalWrite(motorPin4, HIGH);
    delay(2000);    
    
    //And this code will stop motors
    digitalWrite(motorPin1, LOW);
    digitalWrite(motorPin2, LOW);
    digitalWrite(motorPin3, LOW);
    digitalWrite(motorPin4, LOW);
  
}

Downloads