Interfacing L293d motor ic with Arduino uno

Hi,
I am doing a project using arduino uno ,where i need to show the output with motor rotations(clockwise and anticlock wise).So i have done the interfacing of the 12v DC motor using the L293d motor driver ic. But the problem i have got with this is the motor is rotating only in forward direction (i.e clock wise) it is not rotating in the anticlockwise direction.
I have taken the code and also the connections from http://www.erfssn.org/tutorials/arduino/interfacing-dc-motor/
My connections to L293d icare as follows
pin1- vcc(5v)
pin2- Vcc(5v)
pin3- output1 i.e connected to the motor +ve terminal
pin4- gnd
pin6- output2i.e connected to the motor’s -ve terminal
pin7- gnd
pin8- Actually this should be connected to +12v powersupply(extrnal) but i dont have it at present ,so i have connected it to the +5v
pin16-Vcc(5v)
and the digital pin 7 of arduino to pin3 of L293d ic (i.e o/p 1)
digital pin 6 of arduino to pin6 of L293d ic(i.e o/p 2)
So with all these connections the motor is rotating only in clockwise direction,but i cant get my motor turned in anti clockwise.
So please help if i`m wrong with connections or the code and correct me at the earliest

Post your code. Maybe that is where the problem lies.

...R

You need to wire the inputs to the arduino outputs not connect them to fixed levels.
Read this:-

and the digital pin 7 of arduino to pin3 of L293d ic (i.e o/p 1)
digital pin 6 of arduino to pin6 of L293d ic(i.e o/p 2)

So you are wiring the motor outputs to arduino outputs? Sounds like you might have damaged something.

To, Robin2

hi,thanks for ur response I have taken the code from http://www.erfssn.org/tutorials/arduino/interfacing-dc-motor/ and here is my codeint motor_forward = 7; int motor_reverse = 6;

// the setup routine runs once when you press reset: void setup() { // initialize the digital pin as an output. pinMode(motor_forward, OUTPUT); pinMode(motor_reverse, OUTPUT); }

// the loop routine runs over and over again forever: void loop() { digitalWrite(motor_forward,1); //terminal D1 will be HIGH digitalWrite(motor_reverse,0); //terminal D2 will be LOW delay(5000); //creates a 5 seconds delay //Motor will rotate in forward direction for 5 seconds digitalWrite(motor_forward,0); //terminal D1 will be LOW digitalWrite(motor_reverse,1); //terminal D2 will be HIGH delay(5000); //creates a 5 seconds delay //Motor will rotate in reverse direction for 5 seconds digitalWrite(motor_forward,0); //terminal D1 will be LOW digitalWrite(motor_reverse,0); //terminal D2 will be LOW delay(5000); //creates a 5 seconds delay //Motor will stop rotating for 5 seconds //again the loop() will run from the begining until the board is turned OFF }

To,
Grumpy_Mike
I have tried like as you said and connected the digital outputs of the arduino to the inputs of l293d ic
but it didn’t work . I have a doubt and i hope u wont mind answering my question. My question is when u are connecting the digital o/p’s of the arduino to the inputs of the l293d ic, rather to the outputs of L293d,as the i/p’s of the ic are connected to pin1-i/p 1-VCC and pin2- i/p 2 -gnd alwys
so even when u connect the dig outs of arduino to the i/p’s of l293d ic its levels wont get changed ,that is what i feel.
so kindly look after my doubt and clarify it at the earliest

Hi,

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png or pdf?

Tom...... :)

It's very difficult to follow with no schematic and the code not in code tags, but....

pin8- Actually this should be connected to +12v powersupply(extrnal) but i dont have it at present ,so i have connected it to the +5v

You say you have the 293's pin 8 connected to 5V not 12V, so at most your 12V motor will get 5V. In fact it will be less since the 293 drops about 2V (I'm not sure of the exact value). So, you probably have about 3V for a 12V motor and I'm surprised it turns at all.

But why one way and not the other?- I do recall reading that motors are not totally symmetrical, and have a "good" direction and a "bad" one: I'm guessing that it's just a bit of luck that your 12V motor's turning in one direction with 3V and the 3V isn't enough to make it go in its "bad" direction.

When you say "the 5V" do you mean the Arduino 5V? It probably can't provide enough current, let alone the fact that it's 5V not 12V.

This whole discussion is kind of meaningless until you get the right voltage to the 293.

csaipraveenkumar:
To,
Grumpy_Mike
I have tried like as you said and connected the digital outputs of the arduino to the inputs of l293d ic
but it didn’t work . I have a doubt and i hope u wont mind answering my question. My question is when u are connecting the digital o/p’s of the arduino to the inputs of the l293d ic, rather to the outputs of L293d

You must never connect outputs together. The output of the L293 must be connected to the motor, then inputs of the L239 must be connected to an arduino output.

It is very likely you are doing something very silly but until you post your schematic we can’t put you right.

hi,
I have found my mistake i’m wrong with the connections ,I have modified my connection and I am attaching the hand drawn picture of my setup.kindly have a look at it .
The connections in the picture i have attached are same as u said to do in the just previous reply.
But i didnt find my motor rotating in reverse direction . Here is the code which i have used

int pin7=7;
int pin6=6;

void setup(){
pinMode(pin7,OUTPUT);
pinMode(pin6,OUTPUT);
}

void loop(){
delay(2000);
digitalWrite(pin7,HIGH);
digitalWrite(pin6,LOW);
delay(4000);
digitalWrite(pin7,LOW);
digitalWrite(pin6,LOW);
delay(3000);
digitalWrite(pin6,HIGH);
digitalWrite(pin7,LOW);
delay(4000);
digitalWrite(pin7,LOW);
digitalWrite(pin6,LOW);
}
so please look into this and provide me some solution at the earliest

prjct1.jpg

I think you should try it with the right voltage: the motor's probably getting about 3V.

But meanwhile, put your voltmeter on the outputs to see if the chip's actually reversing the polarity. Or put an led and resistor across the output in both directions to check.

Try the other side of the chip.

Swop the wires to the motor to see if the "reverse" works when it's "forward".

Have you got a connection between the Arduino GND and the L293D GND pins? It is not shown on your circuit diagram.

If not, then you need one, so that the the L293D inputs see the correct logic levels.

JohnLincoln: Have you got a connection between the Arduino GND and the L293D GND pins? It is not shown on your circuit diagram.

I wondered about that too, but it's implicit in him marking gnd on the Arduino and gnd on the 293; but as you say, it's not explicitly shown, so you may be right.

Personally, I reckon it's unfair to expect a 12V motor to run off about 3, though.

Sorry for the inconvenience i have connection in my circuit between arduino gnd and l293d gnd but i have forgotten to show it here.Now i am attaching a picture showing the connection between arduino gnd
and L293d gnd.So kindly look at it and provide me solution.

prjct2.jpg

csaipraveenkumar: provide me solution.

I made some suggestions already- did you:

  • Try with 12V on the 293's pin 8 not 5V?
  • Measure the voltage on the 293 outputs to see if it reverses polarity, or test with led?
  • Reverse the wires to the motor to see if the motor actually spins the other way?
  • Try the other side of the 293?

That's 4 things to try but so far you haven't said if you did or not.

  1. presently i dont have a 12v powersupply(i.ebattery) so i didnt try the first suggestion but i tried rest all suggestions

2.while the program is executed (running ) ,I have placed the voltmeter and checked the voltage across pin 2 and also pin 7 of l293d ic, when the pin2 is made high and pin 7 made low then it is showing the readings correctly i.e 5v and 0v,but when the controller is executing the other statements which
digitalWrite(pin6,HIGH);digitalWrite(pin7,LOW);
makes the motor rotate in reverse direction ,the voltmeter is not showing any change in the voltage readings and also the motor is rotating in forward(clockwise direction) only not in reverse(anticlockwise)

3.yes I have reversed the wires to the motor and checked ,the motor is spinning in reverse direction .

4.yes i have tried connecting on the other side of the l293d ic but the motor is not rotating at all in any direction but i am getting the voltage at pin10 as 5v and the voltage at pin 15 as 0v,but the motor is not getting rotated I cant find the reason

Hi,
I am doing project based on ir sensor using arduino uno. The problem i have with the ir sensor circuit is it is not detecting presence of the objects at a distance greater than 1cm.I could not find the reason for it. I am attaching a pic which shows the ir sensor circuit. kindly have a look at it and please tell me the reason for it.The components in the ir sensor circuit are

  1. ir transmitter
  2. ir receiver
  3. lm567 IC
  4. 1k resistors (3)
  5. 10kresistors (1)
  6. 22k resistors(1)
  7. 470 resistor(1)
  8. BC 547 transistor(1)
  9. 1uf,63v capacitor(1)
  10. 0.1uf capacitor(2)
  11. 0.2uf capacitor(1)

irsens.jpg

With the emitter and receiver parallel like that, I'd say there's noting reflecting back into the receiver.

hi,thanks for ur reply, ok i got ur idea but what would u suggest me to do then ,to increase the range

but when the controller is executing the other statements which digitalWrite(pin6,HIGH);digitalWrite(pin7,LOW); makes the motor rotate in reverse direction ,the voltmeter is not showing any change in the voltage readings and also the motor is rotating in forward(clockwise direction) only not in reverse(anticlockwise)

So have you checked with your voltmeter in the above case that pin 6 on the arduino is reading high and pin 7 is reading low? That is do the Arduino signals swap over but the L293 does not?

praveen1550: what would u suggest

You might find this helpful.