ARDUINO BOT NOT TURNING BACK AND LEFT.

I made an Arduino bot which is controlled using l293d motor driver.I used a TV REMOTE AND TSOP IR RECEIVER to control the bot.

I changed the IRrec code from IR library, to get the the bot working.

THE BOT MOVES PERFECTLY IN THE FORWARD AND RIGHT DIRECTIONS, ie. both motors are moving in both cases, but for back,and left ONLY MOTOR2 is rotating in the desired direction, whereas motor1 is not moving. please help.

here is the code:-

#include <IRremote.h>

int motor1Pin1 = 10;
int motor1Pin2 = 9;
int enablePin1 = 11;
int motor2Pin1 = 3;
int motor2Pin2 = 4;
int enablePin2 = 5;

int RECV_PIN = 2;

IRrecv irrecv(RECV_PIN);

decode_results results;

void forward()
{
digitalWrite(motor1Pin1,LOW);
digitalWrite(motor1Pin2,HIGH);
digitalWrite(motor2Pin1,LOW);
digitalWrite(motor2Pin2,HIGH);
}

void right()
{
digitalWrite(motor1Pin1,LOW);
digitalWrite(motor1Pin2,HIGH);
digitalWrite(motor2Pin1,HIGH);
digitalWrite(motor2Pin2,LOW);
}
void left()
{
digitalWrite(motor1Pin1,HIGH);
digitalWrite(motor1Pin2,LOW);
digitalWrite(motor2Pin1,LOW);
digitalWrite(motor2Pin2,HIGH);
}
void back()
{
digitalWrite(motor2Pin1,HIGH);
digitalWrite(motor1Pin1,HIGH);
digitalWrite(motor2Pin2,LOW);
digitalWrite(motor1Pin2,LOW);

}

void stop1()
{
digitalWrite(motor1Pin1,LOW);
digitalWrite(motor1Pin2,LOW);
digitalWrite(motor2Pin1,LOW);
digitalWrite(motor2Pin2,LOW);
}

void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver

pinMode(motor1Pin1, OUTPUT);
pinMode(motor1Pin2, OUTPUT);
pinMode(motor2Pin1, OUTPUT);
pinMode(motor2Pin2, OUTPUT);
pinMode(enablePin1, OUTPUT);
pinMode(enablePin2, OUTPUT);
digitalWrite(enablePin1, HIGH);
digitalWrite(enablePin2, HIGH);
}

void loop() {
if (irrecv.decode(&results)) {
if(results.value==12583000){
Serial.println(“forward()”);
forward();
delay(500);
stop1();
}

else if(results.value==12583003){
Serial.println(“right()”);
right();
delay(500);
stop1();
}

else if(results.value==12583001){
Serial.println(“back()”);
back();
delay(500);
stop1();
}

else if(results.value==12583002){
Serial.println(“left()”);
left();
delay(500);
stop1();
}
irrecv.resume();

}
delay(100);
}

You really should have read the How to use this forum - please read post at the top of the index page and How to use this forum before posting.

ie Your code and any error messages should always be placed between code tags. Posting it inline as you have done makes it much harder to read or copy and paste for diagnosis.

It's still not too late to edit your post and do this. You'll make potential helpers much happier. :)