arduino ir problems

I am using the arduino for an ir project that turn an led on or off using a remote I have it all working but it wont work unless it is plugged in to the computer the is the code have any suggestions

#include <IRremote.h>

int RECV_PIN = 3;

int reversePin = 4;

IRrecv irrecv(RECV_PIN);

decode_results results;

void setup()
{
{
Serial.begin(9600);
irrecv.enableIRIn(); // Start receiver
pinMode(reversePin, OUTPUT); //sets the digital pin as output
}

}

void loop(){
{
if(irrecv.decode(&results)){
long int decCode=results.value;
Serial.println(decCode);
switch(results.value){
case -1:
Serial.println("Forward");
digitalWrite(reversePin, HIGH); //sets the led on
break;
case 13:
Serial.println("Stop");
digitalWrite(reversePin, LOW); // sets the led off
break;
default:
Serial.println("Waiting...");

}

irrecv.resume();//receive the next value
}
}

}

Sounds like a hardware problem. How is everything wired?

the ir on pin 3 and pin 4 is the led but i think i half to have the serial monitor in order for it to work don't know how to change that.

To get the serial monitor click on the magnifying glass icon at the top right hand corner of the window.
Read the how to use this forum sticky and post you code correctly.

buttlicker:
the ir on pin 3 and pin 4 is the led but i think i half to have the serial monitor in order for it to work don't know how to change that.

Is the IR receiver connected to power and ground?

Is the LED connected to power or ground and does it have a current limiting resistor?

Yes I hooked the ir to ground and I am not using a resister dont know what ohms I need but the led works

You need a resistor to protect both the Arduino and IR LED. See this for why:-
http://www.thebox.myzen.co.uk/Tutorial/LEDs.html

Now you say:-

I have it all working but it wont work unless it is plugged in to the computer

When it is not plugged into the computer how are you powering the Arduino?

With a 9 valt batterie

And have you measured the voltage on that battery when it is connected up to the arduino?

Try and I think you will see your problem.