My 4WD Car with IR almost can't move.

This is my code.

const int IN1 = 7;
const int IN2 = 6;
const int IN3 = 5;
const int IN4 = 4;

bool b_run = false;
String MY_DIRECTON;

#include "IRremote.h"
int receiver = 11; // Signal Pin of IR receiver to Arduino Digital Pin 11
IRrecv irrecv(receiver);           // create instance of 'irrecv'
decode_results results;            // create instance of 'decode_results'
void translateIR() // takes action based on IR code received
// describing Remote IR codes 
{
  Serial.println(results.value, HEX);      
  String hex_current_cmd;

  hex_current_cmd = String(results.value);  
  
  if(hex_current_cmd == String(0xFF629D) )//0xEAB7BACD
  {
    b_run = true;
    MY_DIRECTON = "FORWARD";
  }
  
   if(hex_current_cmd == String(0xFFC23D) )
  {
    b_run = true;
    MY_DIRECTON = "RIGHT";
  }
   if(hex_current_cmd == String(0xFF22DD) )
  {
    b_run = true;
    MY_DIRECTON = "LEFT";
  }
   if(hex_current_cmd == String(0xFFA857) )
  {
    b_run = true;
    MY_DIRECTON = "BACKWARD";
  }
  
  // if(hex_current_cmd == String(0xFFFFFFFF) )//0xEAB7BACD
  {
    b_run = true;
  }

// 
}


//const int ENA = 9;
//const int ENB = 3;
void setup() {
  Serial.begin(9600);

  pinMode (IN1, OUTPUT);
  pinMode (IN2, OUTPUT);
  pinMode (IN3, OUTPUT);
  pinMode (IN4, OUTPUT);
  //pinMode (ENA, OUTPUT);
  //pinMode (ENB, OUTPUT);
  // put your setup code here, to run once:
  Serial.println("IR Receiver Button Decode"); 
  irrecv.enableIRIn(); // Start the receiver
  
}

void loop() {
  //analogWrite(ENA, 255);
  //analogWrite(ENB, 255); 

  // digitalWrite(IN1, HIGH);
  // digitalWrite(IN2, LOW);
  // digitalWrite(IN3, HIGH);
  // digitalWrite(IN4, LOW);
      // side_a(1);
      // side_b(1);
      // return;
  b_run = false;
  
  if (irrecv.decode(&results)) // have we received an IR signal?
  {
    translateIR(); 
    irrecv.resume(); // receive the next value
  }
  delay(100); 
  if(b_run)
  {
    if(MY_DIRECTON == "FORWARD")
    {
      side_a(1);
      side_b(1);
    }
    
    if(MY_DIRECTON == "BACKWARD")
    {
      side_a(-1);
      side_b(-1);
    }
    
    if(MY_DIRECTON == "RIGHT")
    {
      side_a(-1);
      side_b(1);
    }
    
    if(MY_DIRECTON == "LEFT")
    {

      side_a(1);
      side_b(-1);
    }
  }
  else
  {
    side_a(0);
    side_b(0);
  }
  
  

  // put your main code here, to run repeatedly:
}

void side_a(int direction)
{
  if(direction == 1)
  {
    digitalWrite(IN1, HIGH);
    digitalWrite(IN2, LOW);   
  }
  
  if(direction == -1)
  {
    digitalWrite(IN1, LOW);
    digitalWrite(IN2, HIGH);   
  }
  
  if(direction == 0)
  {
    digitalWrite(IN1, LOW);
    digitalWrite(IN2, LOW);   
  }
}


void side_b(int direction)
{
  if(direction == 1)
  {
    digitalWrite(IN3, HIGH);
    digitalWrite(IN4, LOW);   
  }
  
  if(direction == -1)
  {
    digitalWrite(IN3, LOW);
    digitalWrite(IN4, HIGH);   
  }
  
  if(direction == 0)
  {
    digitalWrite(IN3, LOW);
    digitalWrite(IN4, LOW);   
  }
}

And I capture the video for this issue

I want to use IR to control my car but I find the wheel almost can't run....

I feel so sad when I run it on my arduino board.

Do I miss something?

Does the power is too low or I should not use the IR for controlling my 4WD Car?

By the way , I use l298n to control my 4 WD car.

Battery's + connect the 12v of l298n.

Battery's - connect the GND of l298n.

The GND of l298n connect the GND of my arduino board.

IR‘s + and - connect my arduino board.

The battery is AA 1.5v .

There are four battery for the l298n.

The graph of the relation for arduino, l298n, IR and battery as below link.

This is my code.

Why not post it here to make it easier to access

Ok, I had updated my post.

Hi, 4AA is not enough because of the L209N voltage drops. You need 6AA.

Here's one the runs well on 6AA:

http://arduino-info.wikispaces.com/RobotKitMenu-5

You will have much better luck with a modern motor driver, like one of these from Pololu.

Hi,
Where have you positioned your IR sensor?

From the video half the time it appears to be a reception problem.
Get the IR sensor up out of the hardware and on top of the car where it can see the remote control.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Tom... :slight_smile:

TomGeorge:
Hi,
Where have you positioned your IR sensor?

From the video half the time it appears to be a reception problem.
Get the IR sensor up out of the hardware and on top of the car where it can see the remote control.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Tom... :slight_smile:

I had updated my post as the relation link.
I draw that by hand.@@

terryking228:
Hi, 4AA is not enough because of the L209N voltage drops. You need 6AA.

Here's one the runs well on 6AA:

http://arduino-info.wikispaces.com/RobotKitMenu-5

It is hard to find the battery for 3v AA.

I had fixed the battery box.

I want to use 12v to get the best performance if the problem is the volt.