HELP WITH BLINKING LED USING 433Mhz RF REMOTE

Hi,

I'm a newbie to Arduino programming, and I'm building one light controller for an RC car with an 433mhz remote, but I'm stuck and appreciate all the help to solve this problem.

I apologize if are topics about this in the Forum, but I searched and didn't find any topic regarding this specific problem. So, basically I want when one of the remote button's is pressed, the led starts blinking at an specific rate, and when the same button is pressed for the second time, the led turns off

The code is working well when I press the button the first time, but then it doesn't receive any more inputs from the remote. And in the second Function when I press the button one time the led turns on, and when I press the second time the led turns off.

I think it's because in the function the code is inside an while loop, but its the only way I found to make the led blink, if I remove the While the led only gives a tiny flash and turns off.

Can anyone help me to solve this?

Here is my code:

#include <RCSwitch.h>

RCSwitch mySwitch = RCSwitch();

enum { BounceMS=50, BlinkMS=500 };

int LED_04 = 6;
int LED_05 = 7;

boolean ledPin04 = LOW;
boolean ledPin05 = LOW;

unsigned long previousMillis = 0;

//COUNT TIMES EACH BUTTON IS PRESSED
int btn1_times_pressed = 0; //count the times btn1 was pressed
int btn2_times_pressed = 0; //count the times btn2 was pressed

void setup() {
  Serial.begin(9600);
  mySwitch.enableReceive(0);  // Receiver input on interrupt 0 (D2)
  pinMode(2, INPUT); // Define D2 as input
  pinMode(LED_04, OUTPUT);
  pinMode(LED_05, OUTPUT);
}

void loop() {
   
  if (mySwitch.available()) {
    Serial.print("Received ");
    Serial.println( mySwitch.getReceivedValue() );
    unsigned long int num = mySwitch.getReceivedValue();
    Serial.println(num);
    
    switch (num)
    {
     //----------------- FUNCTION 01 - BLINK LED -------------------
     case 14626465: btn1_times_pressed += 1;
                    Serial.println(btn1_times_pressed);
                    if (btn1_times_pressed == 1){
                        Flash();
                    }
                    if (btn1_times_pressed == 2){
                      ledPin04 = LOW;
                      btn1_times_pressed = 0;
                    }
                    break;

      //----------------- FUNCTION 02 - TURN LED ON / OFF -------------------
     case 14626466: btn2_times_pressed += 1;
                    if (btn2_times_pressed == 1){
                      ledPin05 = HIGH;
                    }
                    if (btn2_times_pressed == 2){
                      ledPin05 = LOW;
                      btn2_times_pressed = 0;
                    }
                    break;                
   }

    digitalWrite (LED_04, ledPin04);
    digitalWrite (LED_05, ledPin05);
    unsigned long time_now = millis();
    int ck = 500;
    while(millis() < time_now + ck)
    {;}
    mySwitch.resetAvailable();
  }
}

void Flash()
{
  while (btn1_times_pressed == 1)
  {
  digitalWrite(LED_04, (millis())%(2*BlinkMS) < BlinkMS);
  } 
}