ir and IRremote libary hang and stop work in recive mode please help

hello all,

I want to test and learn about IR,
I found this libary IRremote in most posts in this forum all say this is very good libary i try to use it but

when recive work ok and only stop if i use any delay function
here is my code

#include <IRremote.h>

int RECV_PIN = 2;
IRrecv irrecv(RECV_PIN);
 decode_results results;


void setup() 
{
 
  Serial.begin(9600) ;
  Serial.println("IR code reception") ;
  irrecv.enableIRIn(); // Start the ir receiver
}

void loop()
{
 

  if (irrecv.decode(&results)) {
    Serial.println(results.value, DEC);
    
    if(results.value == 33489151)
{
     digitalWrite(10,  HIGH);
   delay(500);
     digitalWrite(10, LOW);
 }   

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


}

when i run it all ok but stop in case

if(results.value == 33489151)
{
     digitalWrite(10,  HIGH);
   delay(500);
     digitalWrite(10, LOW);
 }

when in removed the

delay(500);
digitalWrite(10, LOW);

work good but only when i press the button,
what’s is the wrong in my code


thank you so much

The smart thing to do would be to have one button turn the LED on and another button turn it off.

What do you mean by "when recive work ok and only stop if i use any delay function"? Do you mean that the receiver stops working during the delay? Or that no button press actions occur after the delay ends?

If it is the former, live with it. Everything is working as designed.

If it is the latter, the blink with delay example should get you pointed in the right direction.

thanks for reply, i mean "when recive work ok and only stop if i use any delay function"

when the results.value == 33489151 it will do this

   digitalWrite(10,  HIGH);
   delay(500);
     digitalWrite(10, LOW);

after this no countine, the arduino stop recive any command from ir, when i use the Serial.println it also stop sending to Serial any output

thank you