Hello, I am experimenting with the L293D chip to power a small DC motor.
I have the chip hooked up so that both sides power my one motor, hopefully resulting in a little higher output amp potential as compared to powering the motor with just one side of the chips pins (?).
My simple program is working fine, except there is no braking force being applied when both direction pins are either both LOW, or both HI. Am I doing something wrong in the code, is the L293D hooked up incorrectly, or is it something with the particular motor that I am using?
I have tried the motor brake with the same code just using one side of the chip, with the same results.
I have tried two different motors with the same results. I can measure that both direction pins are going HIGH during the brake command (4.9v), but there is no braking resistance in the motor.
I have the L293D enable pins permanently wire to HIGH, and there is a description of the rest of the pin hook ups at the top of my code.
Any advice, help, suggestions are appreciated!
/* DC motor speed and direction using L293DNE IC (Texas Instm) 10-3-2012
L293DNE pinouts, set up for one motor being driven by both sets of H-bridges
Pin 1, 9, 16 to +5V
Pin 2 & 15 to Arduino PWM pin 5
Pin 3 & 14 to motor lead A
Pin 4, 5, 12 , 13 to Grnd
Pin 6 & 11 to motor lead B
Pin 7 & 10 to Arduino PWM pin 6
Pin 8 to +V battery, battery negative to common Grnd
*/
int motorPin1 = 5; // direction pin to Driver board Pin "D1", pins 7 & 10 on L293D chip
int motorPin2 = 6; // direction pin to Driver board Pin "D2", pins 2 & 15 on L293D chip
//
void setup () {
pinMode(motorPin1,OUTPUT); //set pin 3 as output, L293D direction 1
pinMode(motorPin2,OUTPUT); // set pin 4 as output, L293D direction 2
}
//
void loop() {
motorSpin();
}
//
int motorSpin(){
analogWrite(motorPin1,255); // PWM the direction pin (L293D pin 2)
digitalWrite(motorPin2,LOW);
delay(1000);
digitalWrite(motorPin1,HIGH); // should be brake
digitalWrite(motorPin2,HIGH);
delay(2000);
digitalWrite(motorPin1,LOW); // motor goes the other direction
analogWrite(motorPin2,255); // PWM the other direction pin (L293D pin 7)
delay(1000);
digitalWrite(motorPin1,HIGH); // another brake
digitalWrite(motorPin2,HIGH);
delay(2000);
}