## Friday, 2 October 2015

### Circuit diagram of L293d motor driver and how to wire it up

After seeing some complicated circuit diagram of L293D motor driver online. I thought why not make it more easier for people. And that's why in this post I'm sharing a colourful circuit diagram of L293D. So that you can clearly understand which wire is going where.

In the diagram above you can see all the wires are in different colour except for both motor wires. Well, I've made it one colour for both, because the pin 3, 6, 11 and 14 can turn into + or - at any time. So I though there is no point of making  them in different colour.

OK, let's go through some important pins. Pin 3 and 6 is for left motor and pin 11 and 14 is for right motor. Pin 1, 9 and 16 for Arduino 5v and Pin 4, 5, 12 and 13 is for GND of both Arduino and the external power. Pin 2 and 7 is for controlling left motor and pin 10 and 15 is to control the right motor. And finally the pin number 8 is for v in of external power.

Now let us see the sketch, but before I share the sketch let me tell you what it actually does.
• It starts with 2 seconds delay, just to give some time to settle down when you press the reset button.
• Turns on the green LED to let you know that it's ready to go.
• Goes forward 2 seconds.
• Turns left.
• Comes back.
• Turns right
• Comes back
• Goes backward for 2 seconds.
• It will do all the above tasks once then will stop, if you want to make it do again then press the reset button.
The sketch

 int lmotorf = 2; int lmotorb = 3; int rmotorf = 4; int rmotorb = 5; int greenled = 6; // the setup routine runs once when you press reset: void setup() {                 // initialize the digital pin as an output.   pinMode(lmotorf, OUTPUT);   pinMode(lmotorb, OUTPUT);   pinMode(rmotorf, OUTPUT);   pinMode(rmotorb, OUTPUT);   pinMode(greenled, OUTPUT);   delay(2000);   digitalWrite(greenled, 1);   delay(500);   digitalWrite(greenled, 0);   delay(10);      digitalWrite(lmotorf, HIGH);   // turn the leftforward on.   digitalWrite(rmotorf, HIGH);  // turn the rightforward on.   delay(2000);      // wait for a miliseconds   digitalWrite(lmotorf, LOW);  // turn the leftforward off.   digitalWrite(rmotorf, LOW); // turn the rightforward off.   delay(1000);     digitalWrite(rmotorf, HIGH);   delay(500);   digitalWrite(rmotorf, LOW);   delay(1000);   digitalWrite(rmotorb, HIGH);   delay(500);   digitalWrite(rmotorb, LOW);   delay(1000);     digitalWrite(lmotorf, HIGH);   delay(500);   digitalWrite(lmotorf, LOW);   delay(1000);   digitalWrite(lmotorb, HIGH);   delay(500);   digitalWrite(lmotorb, LOW);   delay(1000);     digitalWrite(lmotorb, HIGH);    digitalWrite(rmotorb, HIGH);   delay(2000);   digitalWrite(lmotorb, LOW);     digitalWrite(rmotorb, LOW);   delay(50);   } // the loop routine runs over and over again forever: void loop() {              delay(50);             }

Few pin names which you might not have understood.
• lmotorf = Left motor forward.
• lmotorb = Left motor backward.
• rmotorf = Right motor forward.
• rmotorb = Right motor backward.

Just by getting control of the motors you can do lot of things. For example moving robotic arms up and down or turning it side to side and so on. This is a simple sketch, but just by editing a bit you can control the motor on your command. If you didn't understand something, please let me know in the comments below.

Let's see the sketch in action

• l293d motor driver with motor connection
• l293d ckt diagram
• l293d diagram
• l293d motor driver circuit diagram
• l293d motor driver pin diagram
• l293d motor driver
• 4 motor driver circuit diagram
• circuit diagram for motor drive
• diagram of l293d
• image of l293d motor driver
• motor drive circuit from l293d
• motor driver ic l293d circuit

#### 1 comment:

1. Thanks/Gracias!

Me sirvio colega!