Controlling 2 motors with L293D chip

Hello
I am having trouble getting two motors run how I want them to using an L293D motor driver. I found and old CD motor cartridge and thought I could use it in a project, if I could make the two motors run as I desire. If you can see the picture The lower Motor-1 moves the carraige up and down. (I can make it do that). I'd like to make the carraige go up and pause while Motor-2 runs a few seconds. Then the carraige should go down again. Using this code, the carraige goes up, motor-2 spins, but but the carraige won't go down but tries to go higher.

Any help with this would be greatly appreciated.

type or paste code here

//Motors code. Motor one drives lower unit up, then motor two spins for a few seconds
//after which motor one returns down

int enable3 = 3;
int enable9 = 9;

int In1 = 5;
int In2 = 10;

int In3 = 6;
int In4 = 11;

void setup(){

pinMode(enable3, OUTPUT);
pinMode(enable9, OUTPUT);

pinMode(In1, OUTPUT);
pinMode(In2, OUTPUT);

pinMode(In3, OUTPUT);
pinMode(In4, OUTPUT);
}

void loop(){
//----------------------------------motor 1 engaged, climbing!
analogWrite(enable3, 150); // Speed(0 to 255)

digitalWrite(In1, HIGH); //Motor moves carraige up

digitalWrite(In2, LOW);

delay(1400);

digitalWrite(In1, LOW); //Carraige stops

digitalWrite(In2, LOW);

delay(7000); //pause 1 secon
//------------------------------------motor 1 off
//------------------------------------motor 2 engaged, spinning.

analogWrite(enable9, 255);

analogWrite(In3, HIGH);

delay (3000);

digitalWrite(In3, LOW);

delay(1500);

//------------------------------------motor 2 off
//------------------------------------Motor 1 Engaged in reverse, descending.

analogWrite(enable3, 150);

digitalWrite(In1, LOW);

digitalWrite(In2, HIGH);

delay(1350);

digitalWrite(In1, LOW);

digitalWrite(In2, LOW);

delay(4000);

type or paste code here

}


You cannot use the Arduino 5V output as a motor power supply, so try a 6xAA battery pack instead. Don't forget to connect the grounds.

The L293D is an ancient, extremely inefficient motor driver chip, and up to half the battery voltage is lost as heat. You will have much better luck with a modern motor driver, like this one.

Thanks for your input. I can easily use a 6V source.

Well, JR,
Using a 6Volt power source did make it run better. Much better. It did not, however fix the odd motor operation. What I did was turn on the Builtin Led for 1/2 a sec before starting M2, then turning it off after M2 stopped. This makes both motors do what I wanted. Something to do with the code needing to pause between turning one off and one on. I'm not good enough at coding to know what else to do. This works for me though. Thanks again

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.