motors not starting- l293d motor controller

 

Hello guys

I made the connections as per my knowledge. However, the motors dont work. Could you help me out??

Sorry for the confusing connections. And, i have powered my arduino through the usb cable.

Thankyou guys, you know this one!!\

l293dnotworking.png

and here is the program

int motor_left[] = {7, 6};

int motor_right[] = {5, 4};

 

// --------------------------------------------------------------------------- Setup

void setup() {

Serial.begin(9600);

 

// Setup motors

int i;

for(i = 0; i < 2; i++){

pinMode(motor_left[i], OUTPUT);

pinMode(motor_right[i], OUTPUT);

}

 

}

 

// --------------------------------------------------------------------------- Loop

void loop() { 

 

drive_forward();

delay(1000);

motor_stop();

Serial.println("1");

 

drive_backward();

delay(1000);

motor_stop();

Serial.println("2");

 

turn_left();

delay(1000);

motor_stop();

Serial.println("3");

 

turn_right();

delay(1000);

motor_stop();

Serial.println("4"); 

 

motor_stop();

delay(1000);

motor_stop();

Serial.println("5");

}

 

// --------------------------------------------------------------------------- Drive

 

void motor_stop(){

digitalWrite(motor_left[0], LOW); 

digitalWrite(motor_left[1], LOW); 

 

digitalWrite(motor_right[0], LOW); 

digitalWrite(motor_right[1], LOW);

delay(25);

}

 

void drive_forward(){

digitalWrite(motor_left[0], HIGH); 

digitalWrite(motor_left[1], LOW); 

 

digitalWrite(motor_right[0], HIGH); 

digitalWrite(motor_right[1], LOW); 

}

 

void drive_backward(){

digitalWrite(motor_left[0], LOW); 

digitalWrite(motor_left[1], HIGH); 

 

digitalWrite(motor_right[0], LOW); 

digitalWrite(motor_right[1], HIGH); 

}

 

void turn_left(){

digitalWrite(motor_left[0], LOW); 

digitalWrite(motor_left[1], HIGH); 

 

digitalWrite(motor_right[0], HIGH); 

digitalWrite(motor_right[1], LOW);

}

 

void turn_right(){

digitalWrite(motor_left[0], HIGH); 

digitalWrite(motor_left[1], LOW); 

 

digitalWrite(motor_right[0], LOW); 

digitalWrite(motor_right[1], HIGH); 

}

 

What was Wrong

Hello, glad to hear its working, what was wrong?  A lot of times the “mistake” has a valuable lesson for the rest of us.

kingart3…i forgot to

kingart3…i forgot to connect the -ve of the battery to the gnd…thanks dan m…working as a charm…

Thanks always good to know…

One guy soldered the terminals of the motors together by accident.  I connected my battery pack to the project board backwards, the list goes on and on.

Lots of people have problems with this and we tend to look at the code or other more complicated things first.

A lot of times people get the “hard stuff” right and the “easy stuff” wrong.  I have been doing it my whole life …LOL.