Weird behavior with IR remote controlled car

Hii, this is my first Arduino project and I am trying to make an IR remote controlled car.

I have the following problem: the motors run fine when I upload a sketch to turn them on or off directly, but when I upload a sketch with the IR control code only one motor responds.

Trying to determine the cause of this behavior I found the following: In the full code below the motors are controlled directly (both to turn on when the sketch is uploaded) and they work fine. But when I add this line   ir_receiver.enableIRIn(); // Start the receiver

Then again only the right motor turns on and the left doesn't respond.

Why is this strange behavior when I add this line of code?? any help is appreciated.

#include <IRremote.h>
const unsigned int IR_RECEIVER_PIN = 2;
IRrecv ir_receiver(IR_RECEIVER_PIN);
decode_results results;
void setup() {
   ir_receiver.enableIRIn(); // Start the receiver
 pinMode(7, OUTPUT);
 pinMode(8, OUTPUT);
 pinMode(9, OUTPUT);//analog control of Motor A
 pinMode(3, OUTPUT);//analog control of Motor B
 pinMode(5, OUTPUT);
 pinMode(6, OUTPUT);
}

void loop(){
  
  digitalWrite(7, HIGH);
  digitalWrite(8,LOW);
  analogWrite(9,180);
  digitalWrite(6, HIGH);
  digitalWrite(5,LOW);
  analogWrite(3,180);
}

(deleted)

spycatcher2k:
The IR library uses the same timer as PWM you can't have both!

I assume you mean that the OP needs to choose different PWM pins for the motor? (I am not familiar with the IRemote library)

...R

spycatcher2k:
The IR library uses the same timer as PWM you can't have both!

Thanks for the reply, so using sensor shield could resolve this issue? or what is the usual solution ?