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

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.

Step 1: Materials and Tools

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

Step 2: Connecting the VCC Pins

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

Step 3: Connecting the Ground Pins

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

Step 4: Connecting the Signal Pins

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

Step 5: Connecting the DC Motors

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.

Step 6: Coding and Uploading

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);
  
}
Makerspace Contest 2017

Participated in the
Makerspace Contest 2017