Infra Red controlled car only when pushing button?

I don’t seem anything to do this… I’m making my nephew a RC car because making one is way cheaper than buying one (and in some way even cooler) and it’s kinda done. The thing is: he’s 5. He’s reflexes aren’t really that good. For now, the button you pressed is the direction the car will go, even if you let go off the button. Is there a way to only activate the motors when a button is being pressed? Here’s my code:

#include <IRremote.h>
int RECV_PIN = 3;
IRrecv irrecv(RECV_PIN);
decode_results results;

int bocina = 9;
int frec = 400;
int tiempo = 500;

//Backlights
int a = 5;
int b = 4;

//Front Lights
int c = 7;
int d = 6;

//Engine 1
int IN1 = 12; 
int IN2 = 13;

//Engine 2
int IN3 = 11; 
int IN4 = 10;

void setup()
{
  Serial.begin(9600);
  pinMode(a, OUTPUT);
  pinMode(b, OUTPUT);
  pinMode(c, OUTPUT);
  pinMode(d, OUTPUT);
  irrecv.enableIRIn();
}

void loop()
{  
  if(irrecv.decode(&results))
  {
    Serial.print(results.value, HEX);    
    switch(results.value)
    {
      case 0xE0E006F9:
        digitalWrite(a, HIGH);
        digitalWrite(b, HIGH);
        digitalWrite(c, LOW);
        digitalWrite(d, LOW);
        Serial.println(" Forward");
        digitalWrite (IN1, HIGH);
        digitalWrite (IN2, LOW); 
        digitalWrite (IN3, HIGH);
        digitalWrite (IN4, LOW); 
      break;
      
      case 0xE0E0A659:
        digitalWrite(a, HIGH);
        digitalWrite(b, LOW);
        digitalWrite(c, LOW);
        digitalWrite(d, LOW);
        Serial.println(" Left");
        digitalWrite (IN1, HIGH);
        digitalWrite (IN2, LOW); 
        digitalWrite (IN3, LOW);
        digitalWrite (IN4, HIGH); 
      break;
      
      case 0xE0E046B9:
        Serial.println(" Right");
        digitalWrite(a, LOW);
        digitalWrite(b, HIGH);
        digitalWrite(c, LOW);
        digitalWrite(d, LOW);
        digitalWrite (IN1, LOW);
        digitalWrite (IN2, HIGH); 
        digitalWrite (IN3, HIGH);
        digitalWrite (IN4, LOW); 
      break;
      
      case 0xE0E08679:
        digitalWrite(a, LOW);
        digitalWrite(b, LOW);
        digitalWrite(c, HIGH);
        digitalWrite(d, HIGH);
        Serial.println(" Backwards");
        digitalWrite (IN1, LOW);
        digitalWrite (IN2, HIGH); 
        digitalWrite (IN3, LOW);
        digitalWrite (IN4, HIGH); 
      break;
      
      default:
        digitalWrite(a, LOW);
        digitalWrite(b, LOW);
        digitalWrite(c, LOW);
        digitalWrite(d, LOW);
        Serial.println(" Stop");
        digitalWrite (IN1, LOW);
        digitalWrite (IN2, LOW); 
        digitalWrite (IN3, LOW);
        digitalWrite (IN4, LOW); 
      break;
    }
    irrecv.resume();
  }
}

Any ideas? Is it even possible? My controller doesn’t give the 0xFFFFFFFF when keeping pressed, it just sends the same code over and over.

  if (irrecv.decode(&results))
  {
      //more code here
  }

Once the motor has been started unless the STOP commands are issued it will not stop

If you add an else clause after the if you can write code to be executed when nothing is received

i had already tried that, but that just causes the thing to just move bit by bit :c thanks anyways, though

DukeVonC: i had already tried that, but that just causes the thing to just move bit by bit :c thanks anyways, though

Maybe you did something wrong. If you posted that code someone might could help you. Or you can just frowny face and walk away. It's up to you.

You have to send two codes, like every keyboard does. The first one is the "make" code, telling which button is pressed. The other one is the "break" code, telling the receiver that the button was released.

DrDiettrich: You have to send two codes, like every keyboard does. The first one is the "make" code, telling which button is pressed. The other one is the "break" code, telling the receiver that the button was released.

Not if the transmitter stops sending anything when the button is released, which would seem likely

if (somethingReceived)
{
  //take action based on value received
}
else
{
  //do something else
}

DukeVonC: i had already tried that, but that just causes the thing to just move bit by bit :c thanks anyways, though

you could give it a time limit - say 'FWD' switches the motor 'HIGH' - delay (200) - or more, you can experiment what's suitable given the speed of the motors - and then switch it 'LOW" - until the 'FWD' is pressed again.