IR Remote coding question

Hello all,

I am currently working on a project which uses an IR remote to control an up/ down counter ic. I’m working with the following code:

#include <IRremote.h>

int IRpin = 11;  // pin for the IR sensor 
IRrecv irrecv(IRpin);
decode_results results;

void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
  
  pinMode(13, OUTPUT);//counter up
  pinMode(12, OUTPUT);//counter down
  pinMode(10, OUTPUT);//reset
  
  digitalWrite(10, HIGH);
  digitalWrite(10, LOW);//reset counters
}


void loop() 
{
   
  if (irrecv.decode(&results)) 
    {
      
      irrecv.resume();   // Receive the next value
    }
  
  switch(results.value)
 {

  case 1168:
  // left up
   digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(10);              // wait for a second
  digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
  delay(500);              // wait for a second
  break;
  
  case 3216:
  // left down
   digitalWrite(12, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(10);              // wait for a second
  digitalWrite(12, LOW);    // turn the LED off by making the voltage LOW
  delay(500);              // wait for a second
  break;
  
  case 1808:
  // left +3
  break;
  
  case 304:
  //left reset
  break;
  
  }

The problem I am experiencing is that when I hit a button on the remote, the program seems to hold that remote code and continually carries out the switch case for that code. The desired effect is that the program would take the input, carry out the switch case once, and then wait for the next input. Any suggestions on what I can add to the code to get the desired effect?

Thank you
Mike

X = results.value; . . . switch (X) { case 1168: // left up digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level) delay(10); // wait for a second digitalWrite(13, LOW); // turn the LED off by making the voltage LOW delay(500); // wait for a second

X = 0;

break;

. . .

You wrote:

  if (irrecv.decode(&results)) {
  irrecv.resume();   // Receive the next value
}

switch (results.value) {
  .
  .
  .
}

What you should have written:

  if (irrecv.decode(&results)) {
  switch (results.value) {
      .
      .
      .
  }
  irrecv.resume();   // Receive the next value
}