L293NE Problems

Hello arduiners,

I am having trouble with the TI chip L293NE. I am trying to use it to control a pair of 12v 246mA DC motors in a robot that I am building. I have looked at just about every tutorial online for this IC (and the arduino forums) and I have followed the wiring from the datasheet:

For the time being, I am trying to get it to work with just one motor. I have a program written that keeps one motor control pin low constantly while the other one oscillates between high and low every 2 seconds. This should make the motor turn in one direction for 2 seconds, stop for 2 seconds, and repeat.

I have the arduino plugged into my laptop for power and I am using a separate 12v sealed lead-acid battery to power the motor. When everything is hooked up and running, the motor does not turn. In debugging, I discovered that when I probe one of the digital output pins with a multimeter, the motor will turn in one direction. Probing the other pin will make it turn in the other direction. Alternatively, I can connect one of the motor control pins from the IC (pin 2 or 7) to ground and the motor will turn.

I seem to gather that the arduino cannot pull the voltage at the control pins low enough to make the IC function. Any ideas on why that might be or what I can do to fix it?

In your code, do you have

pinMode(PIN_NUM, OUTPUT);

anywhere? I forget that sometimes, and wonder why things aren't as they should be. :wink:

Angineer:
I have followed the wiring from the datasheet

Just so we're clear - your following figure 5 on page 9, correct? If not - you should be. Please verify and let us know; also, post your code and which pins on the Arduino connect to which pins on the L293 (ideally, a sketch or something of -your- schematic with the Arduino included would be more helpful than saying "I am using the schematic on the datasheet" - I can't tell you the number of times I have read that, only to find the poster didn't follow the schematic).

Yes, I used the schematic in page 9, figure 5. Here is the sketch I am using now--it is a little choppy because I have been trying to debug the problem but I think it should still work:

int enable=7;
int rightf=5;
int rightb=6;

void setup(){
  for(int i=2; i==7; i++){
  pinMode(i, OUTPUT);}
  
  digitalWrite(enable, HIGH);
}

void loop(){
  digitalWrite(rightf, LOW);
  digitalWrite(rightb, LOW);
  
  delay(3000);
  
  digitalWrite(rightf, HIGH);
  digitalWrite(rightb, LOW);
  
  delay(3000);
}

Pin 5 on the arduino goes to pin 2 on the IC, Arduino pin 6 to IC pin 7, and Arduino pin 7 to IC pin 1. My battery's positive terminal goes directly to pin 8 on the IC and the arduino's 5v goes to pin 16 on the IC.

I forgot to mention earlier that I'm not using the diodes suggested in the datasheet; I just used what I had available (1N4148). I don't know if that would impact anything.

Thanks for the help--I have been going a little crazy over this issue.

Angineer:
Yes, I used the schematic in page 9, figure 5. Here is the sketch I am using now--it is a little choppy because I have been trying to debug the problem but I think it should still work:

int enable=7;

int rightf=5;
int rightb=6;

void setup(){
  for(int i=2; i==7; i++){
  pinMode(i, OUTPUT);}
 
  digitalWrite(enable, HIGH);
}

void loop(){
  digitalWrite(rightf, LOW);
  digitalWrite(rightb, LOW);
 
  delay(3000);
 
  digitalWrite(rightf, HIGH);
  digitalWrite(rightb, LOW);
 
  delay(3000);
}




Pin 5 on the arduino goes to pin 2 on the IC, Arduino pin 6 to IC pin 7, and Arduino pin 7 to IC pin 1. My battery's positive terminal goes directly to pin 8 on the IC and the arduino's 5v goes to pin 16 on the IC.

I forgot to mention earlier that I'm not using the diodes suggested in the datasheet; I just used what I had available (1N4148). I don't know if that would impact anything.

Thanks for the help--I have been going a little crazy over this issue.

Ok - your connections sound correct; I am assuming you also have the grounds tied together between the arduino and the L293? The diodes shouldn't be an issue - but re-check their orientations as well.

Finally, regarding your code - change this part:

void setup(){
  for(int i=2; i==7; i++){
  pinMode(i, OUTPUT);}
  
  digitalWrite(enable, HIGH);
}

to:

void setup(){
  for (int i=2; i<8; i++) {
    pinMode(i, OUTPUT);
  }
  
  digitalWrite(enable, HIGH);
}

My thought there is that with your code, pin 7 wasn't being set as an output because the for() loop exits on hitting "7" (which might be the whole issue - so try it first)...

Good luck.

:slight_smile:

:blush:

wow they should have failed me in my programming class...

That was exactly it--thanks so much for the help. Such a simple solution that I just kept overlooking. Thanks again. :slight_smile:

Angineer:
:blush:

wow they should have failed me in my programming class...

That was exactly it--thanks so much for the help. Such a simple solution that I just kept overlooking. Thanks again. :slight_smile:

Happens to all of us... :slight_smile: