IR remote won't work unless the Arduino board is attached to the computer

Hi, I have recently started a minor robotics project where a sumo bots wheels are controlled through an IR remote and receiver. The project works fine until I remove the wire connecting the computer and MEGA board. Then whenever the IR remote is pressed the arduinos L light is lit up instead of the TX light and the project does nothing. I can confirm that the project has power.

Any help would be great,
Thank you in advance.

Hi,
We need to see your wiring schematic and your code, so we can help, my mind reading skills are a little dim today and my chrystal ball is broken!!

Regards

Mel.

#include <AFMotor.h>
#include <IRremote.h>

const int irReceiverPin = 20;
AF_DCMotor motorTwo(2, MOTOR12_64KHZ); // create motor #2, 64KHz pwm
AF_DCMotor motorOne(1, MOTOR12_64KHZ); // create motor #1, 64KHz pwm
AF_DCMotor motorThree(3, MOTOR12_64KHZ); // create motor #2, 64KHz pwm
AF_DCMotor motorFour(4, MOTOR12_64KHZ); // create motor #1, 64KHz pwm
IRrecv irrecv(irReceiverPin); //Creates a variable of type IRrecv
decode_results results;

void setup() {

Serial.begin(9600); //initialize serial monitor
irrecv.enableIRIn(); //enable ir receiver module

Serial.print(“Motor test!”);

motorOne.setSpeed(250); // set the speed to 200/255
motorTwo.setSpeed(250); // set the speed to 200/255
motorThree.setSpeed(250); // set the speed to 200/255
motorFour.setSpeed(250); // set the speed to 200/255
}

void loop() {

if (irrecv.decode(&results)) //if the ir receiver module receiver data
{
Serial.print("irCode: “); //print"irCode: "
Serial.print(results.value, HEX); //print the value in hexdecimal
Serial.print(”, bits: “); //print” , bits: "
Serial.println(results.bits); //print the bits
irrecv.resume(); // Receive the next value
}
delay(600); //delay 600ms
if(results.value == 0xFF18E7) // 2
{
motorOne.run(FORWARD); // turn it on going forward
motorTwo.run(FORWARD); // turn it on going forward
motorThree.run(BACKWARD); // turn it on going forward
motorFour.run(BACKWARD); // turn it on going forward
}
else if(results.value == 0xFF4AB5) // 8
{
motorOne.run(BACKWARD); // turn it on going forward
motorTwo.run(BACKWARD); // turn it on going forward
motorThree.run(FORWARD); // turn it on going forward
motorFour.run(FORWARD); // turn it on going forward
}
else if(results.value == 0xFF38C7) // 5
{

motorTwo.run(RELEASE); // turn it on going forward
motorOne.run(RELEASE); // stopped
motorThree.run(RELEASE); // turn it on going forward
motorFour.run(RELEASE); // turn it on going forward
}
else if(results.value == 0xFF5AA5) // 6
{

motorTwo.run(RELEASE); // turn it on going forward
motorOne.run(FORWARD); // stopped
motorThree.run(RELEASE); // turn it on going forward
motorFour.run(BACKWARD); // turn it on going forward
}
else if(results.value == 0xFF10EF) // 4
{

motorTwo.run(FORWARD); // turn it on going forward
motorOne.run(RELEASE); // stopped
motorThree.run(BACKWARD); // turn it on going forward
motorFour.run(RELEASE); // turn it on going forward
}else{}
}

Here is the image of wiring.

When things don't work when the Arduino is not connected to the PC, there is almost always a power issue or a ground issue.

A schematic would be far more useful that a picture where most of the wires run out of the picture. I can't even see an IR receiver in that picture.

Forget the robot for the moment. Just connect an LED, with current limiting sensor, to the Arduino, along with the IR receiver.

When the IR receiver receives on value, turn the LED on. When it receives a different value, turn it off.

Test with the Arduino connected to the PC. Then test with the Arduino powered by batteries. Let us know the results.

There might not be enough current to power all of the chips and modules connected to your board. Connecting an external power source (via the VIN pin or elsewhere) to supply more current might solve the issue, although I wouldn’t consider myself an Arduino expert like the other two people in this thread.

Thank you very much, changing the batteries to some that provide more current has fixed the problem.

Nosrakeo:
Thank you very much, changing the batteries to some that provide more current has fixed the problem.

I'm having the same (or similar) problem with my IR remote. What battery did you end up using? And what's the specs on the battery?