controlling a robot with tv remote

So i started this project and I wanted to use a remote to control my robot. First let me just explain what my setup is and what hardware I am using because I am sure I'm going to have more questions. I got the Dual motor gearbox from sparkfun and the tank treads : Dual Motor GearBox - ROB-00319 - SparkFun Electronics
I plan on using the SN754410 Quad Half H-Bridge. H-Bridge Motor Driver 1A - COM-00315 - SparkFun Electronics

For my first question the hardware is not relevant. I am simply trying to turn on an led on and off with my remote that I have. When I push the up arrow on the remote once and release, I get the code: 458. then if i push it again once and release I get 10458. The code alternates each time the button is pressed and released. This is true for every button on the remote. Every button seems to have 2 codes. If I push and hold the button It will spam one of the codes, and if I release then press and hold again it spams the other code. What would be the best way to utilize these codes and the controller to drive the robot. I can think of 2 options. The first would be turn the Led High when I hold the button and to turn low when I release it. the second would be to use single key presses instead of holding the button down. For example I press up and release it which would give the code 458 and the led turns High. Then I press it again which gives 10458 and the led goes low. I dont even know how to go about the first option. I thought I knew how to code the second option but I seem to be missing something. The led wont respond to the key presses. Can someone please help me out with the code. I would like examples of both options. Here is the code I am trying to use for the second option. Thanks for any help you guys can provide.

#include <IRremote.h>

int RECV_PIN = 11;

IRrecv irrecv(RECV_PIN);

decode_results results;

void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
pinMode(13, OUTPUT);
}

void loop() {
if (irrecv.decode(&results)) {
Serial.println(results.value, HEX);
irrecv.resume(); // Receive the next value
}
switch(results.value){
case 458:
digitalWrite(13, HIGH);
break;
case 10458:
digitalWrite(13, LOW);
}
}

void loop() {
  if (irrecv.decode(&results)) {
    Serial.println(results.value, HEX);
    irrecv.resume(); // Receive the next value
  }
  switch(results.value){
  case 458:
    digitalWrite(13, HIGH);
    break;
  case 10458:
    digitalWrite(13, LOW);
  }
}

You are switching on the value even if you haven't received one.

Could you elaborate? I am pretty new to programming. I basically copied that code from an instructable. The code he used was as follows.
switch(results.value){
case 50088119:
// do something
break;
case 50073839:
// do something else...
break;
}

Sure, but outside the "if" that code is going to be executed thousands of times a second.

More like this, I would say:

void loop() {
  if (irrecv.decode(&results)) {
    Serial.println(results.value, HEX);

    switch(results.value){
    case 458:
      digitalWrite(13, HIGH);
      break;
    case 10458:
      digitalWrite(13, LOW);
    }  // end of switch

    irrecv.resume(); // Receive the next value

  }  // end of if

}  // end of loop

Oh ok I got it now. Thank you sir!

Hmm that doesn't seem to work either. I understand the { } symbols now but the led still does nothing. Do I need a delay in there somewhere?

I got this to work before with another project but I can't remember what I did. Cant find the sketch.

Ok I got it to work. I changed the HEX to DEC and changed the code to reflect that. Not sure why it didnt like the HEX code but oh well. Thanks for the help. Now I just need to adapt this to my H bridge sketch I made!

Ok so I adapted this to my robot tank. It wasn't doing what I wanted so I figured something was wrong either with the code or the wiring. One of the motors was running when it shouldn't have been. So I made another sketch to make sure the H bridge wasn't malfunctioning. I took out all the code for the other buttons, and just left the code to enable the motors. So basically what should happen is both enable pins and the led should go High. No motors should be running. However that is not the case. One motor turns on when I enable. Is this a wiring problem or is my chip malfunctioning. Ill post the original code, the troubleshooting code and a schematic.

Here is what I had:

  #include <IRremote.h>

int RECV_PIN = 11;     // IR receiver 
int motor1Pin1 = 3;    // pin 7 on SN754410
int motor1Pin2 = 4;    // pin 2 on SN754410
int motor2Pin1= 5;    // pin 10 on SN754410
int motor2Pin2= 6;    // pin 15 on SN754410
int enablePin1 = 9;    // pin 1 on SN754410
int enablePin2 = 10;   // pin 9 on SN754410

IRrecv irrecv(RECV_PIN);

decode_results results;
void setup() 
{
   Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
  pinMode(13, OUTPUT);
  pinMode(motor1Pin1, OUTPUT);
  pinMode(motor1Pin2, OUTPUT);
  pinMode(motor2Pin2, OUTPUT);
  pinMode(motor2Pin2, OUTPUT);
  pinMode(enablePin1, OUTPUT);
  pinMode(enablePin2, OUTPUT);
  
}
void loop() {
  if (irrecv.decode(&results)) {
    Serial.println(results.value, DEC);
    
   switch(results.value){
     case 1036:                        // power button code
    digitalWrite(enablePin1, HIGH);
    digitalWrite(enablePin2, HIGH);
    digitalWrite(13, HIGH);
   break;
     case 66572:                      // power button code
    digitalWrite(enablePin1, LOW);
    digitalWrite(enablePin2, LOW);
    digitalWrite(13, LOW);
   break;
     case 1112:                      // forward button code
    digitalWrite(motor1Pin1, LOW);   
    digitalWrite(motor1Pin2, HIGH); 
    digitalWrite(motor2Pin1, LOW);   
    digitalWrite(motor2Pin2, HIGH);  
   break;
     case 66648:                    // forward button second code
    digitalWrite(motor1Pin1, LOW);
    digitalWrite(motor1Pin2, LOW);
    digitalWrite(motor2Pin1, LOW);
    digitalWrite(motor2Pin2, LOW);
   break;
     case 1113:                      // reverse button code
    digitalWrite(motor1Pin1, HIGH);
    digitalWrite(motor1Pin2, LOW);
    digitalWrite(motor2Pin1, HIGH);
    digitalWrite(motor2Pin2, LOW);
   break;  
     case 66649:                    // reverse button second code
    digitalWrite(motor1Pin1, LOW);
    digitalWrite(motor1Pin2, LOW);
    digitalWrite(motor2Pin1, LOW);
    digitalWrite(motor2Pin2, LOW);
   break; 
     case 1114:                      // left button code
    digitalWrite(motor1Pin1, HIGH);
    digitalWrite(motor1Pin2, LOW);
    digitalWrite(motor2Pin1, LOW);
    digitalWrite(motor2Pin2, HIGH);
   break;
     case 66650:                    // left button second code
    digitalWrite(motor1Pin1, LOW);
    digitalWrite(motor1Pin2, LOW);
    digitalWrite(motor2Pin1, LOW);
    digitalWrite(motor2Pin2, LOW);
   break;
     case 1115:                    // right button code
    digitalWrite(motor1Pin1, LOW);
    digitalWrite(motor1Pin2, HIGH);
    digitalWrite(motor2Pin1, HIGH);
    digitalWrite(motor2Pin2, LOW);
   break;
     case 66651:                    // right button second code
    digitalWrite(motor1Pin1, LOW);
    digitalWrite(motor1Pin2, LOW);
    digitalWrite(motor2Pin1, LOW);
    digitalWrite(motor2Pin2, LOW);
   break;
   }
   irrecv.resume();
  }
    
}

Moderator edit: [code] ... [/code] tags added. (Nick Gammon)

Here is the troubleshooting code:

  #include <IRremote.h>

int RECV_PIN = 11;     // IR receiver 
int motor1Pin1 = 3;    // pin 7 on SN754410
int motor1Pin2 = 4;    // pin 2 on SN754410
int motor2Pin1= 5;    // pin 10 on SN754410
int motor2Pin2= 6;    // pin 15 on SN754410
int enablePin1 = 9;    // pin 1 on SN754410
int enablePin2 = 10;   // pin 9 on SN754410

IRrecv irrecv(RECV_PIN);

decode_results results;
void setup() 
{
   Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
  pinMode(13, OUTPUT);
  pinMode(motor1Pin1, OUTPUT);
  pinMode(motor1Pin2, OUTPUT);
  pinMode(motor2Pin2, OUTPUT);
  pinMode(motor2Pin2, OUTPUT);
  pinMode(enablePin1, OUTPUT);
  pinMode(enablePin2, OUTPUT);

  
}
void loop() {
  if (irrecv.decode(&results)) {
    Serial.println(results.value, DEC);
   switch(results.value){
     case 1036:                        // power button code
    digitalWrite(enablePin1, HIGH);
    digitalWrite(enablePin2, HIGH);
    digitalWrite(13, HIGH);
   break;
      case 66572:                      // power button second code
    digitalWrite(enablePin1, LOW);
    digitalWrite(enablePin2, LOW);
    digitalWrite(13, LOW);
   break;
  }
  }
}

Moderator edit: [code] ... [/code] tags added. (Nick Gammon)

Here is the schematic

On another note, I have to upload the code each time to get it to respond at all. Otherwise the led just blinks. I still have the same problem though, after I upload, with the one motor turning on when I push the enable power button. Any ideas as to why that is?