arduino uno+ HMI nextion 3.5inch

Hi all my friends!
I have some problems with arduino + HMI connection. I think you can help me fix this problem.
-I still cannot complete the code in: void DSbutton bt6
-My aim: when you press bt6 on the 1st HMI, then execute commands in the while loop, when you press bt6 a second time, exit the while loop and turn off all the lights
-problems I do not find the condition to exit the while loop. Can you help me improve this code?
Thanks for reading and able to solve this problem for me
thanks
Here is the code:

#include "Nextion.h"

const int led_01 = 13;
const int led_02 = 12;
const int led_03 = 11;
const int led_04 = 10;
const int led_05 = 9;
const int led_06 = 8;
NexButton b0   = NexButton(1, 1, "b0");
NexButton b1   = NexButton(1, 5, "b1");
NexDSButton bt0 = NexDSButton(1, 2, "bt0");
NexDSButton bt1 = NexDSButton(1, 3, "bt1");
NexDSButton bt2 = NexDSButton(1, 4, "bt2");
NexDSButton bt3 = NexDSButton(1, 6, "bt3");
NexDSButton bt4 = NexDSButton(1, 7, "bt4");
NexDSButton bt5 = NexDSButton(1, 8, "bt5");
NexDSButton bt6 = NexDSButton(2, 2, "bt6");


// Registro al objeto Dual State Button a la lista de eventosTouch
NexTouch *nex_listen_list[] =
{
  &b0, &b1,
  &bt0, &bt1, &bt2, &bt3, &bt4, &bt5, &bt6,
  NULL
};

// Creo que una funcion que ingresara cuando el evento Touch sea detectado
void b0_Apagar(void *ptr);
void b1_Apagar(void *ptr);
void Funcion_bt0(void *ptr);
void Funcion_bt1(void *ptr);
void Funcion_bt2(void *ptr);
void Funcion_bt3(void *ptr);
void Funcion_bt4(void *ptr);
void Funcion_bt5(void *ptr);
void Funcion_bt6(void *ptr);

void setup(void)
{

  nexInit();//Inicio la comunicacion entre el Arduino y la Pantalla

  pinMode(led_01, OUTPUT);
  pinMode(led_02, OUTPUT);
  pinMode(led_03, OUTPUT);
  pinMode(led_04, OUTPUT);
  pinMode(led_05, OUTPUT);
  pinMode(led_06, OUTPUT);

  digitalWrite(led_01, LOW);
  digitalWrite(led_02, LOW);
  digitalWrite(led_03, LOW);
  digitalWrite(led_04, LOW);
  digitalWrite(led_05, LOW);
  digitalWrite(led_06, LOW);

  //Registro  el llamado a la funcion del evento de Dual State Button
  b0.attachPop(b0_Apagar);
  b1.attachPop(b1_Apagar);
  bt0.attachPop(Funcion_bt0, &bt0);
  bt1.attachPop(Funcion_bt1, &bt1);
  bt2.attachPop(Funcion_bt2, &bt2);
  bt3.attachPop(Funcion_bt3, &bt3);
  bt4.attachPop(Funcion_bt4, &bt4);
  bt5.attachPop(Funcion_bt5, &bt5);
  bt6.attachPop(Funcion_bt6, &bt6);
}

void loop(void)
{
  /*
     Cada vez que el evento sea llamado, se direccionara al correspondiente
    evento del componente.
  */

  nexLoop(nex_listen_list);
}

void b0_Apagar(void *ptr)
{
  digitalWrite(led_01, LOW);
  digitalWrite(led_02, LOW);
  digitalWrite(led_03, LOW);
  digitalWrite(led_04, LOW);
  digitalWrite(led_05, LOW);
  digitalWrite(led_06, LOW);
}
void b1_Apagar(void *ptr)
{
  digitalWrite(led_01, HIGH);
  digitalWrite(led_02, HIGH);
  digitalWrite(led_03, HIGH);
  digitalWrite(led_04, HIGH);
  digitalWrite(led_05, HIGH);
  digitalWrite(led_06, HIGH);
}

void Funcion_bt0(void *ptr) {
  uint32_t Estado_dual;/* Consigo el valor del estado del componente. */
  bt0.getValue(&Estado_dual);

  if (Estado_dual) {
    digitalWrite(led_01, HIGH);
  }
  else {
    digitalWrite(led_01, LOW);
  }
}

void Funcion_bt1(void *ptr) {
  uint32_t Estado_dual;/* Consigo el valor del estado del componente. */
  bt1.getValue(&Estado_dual);

  if (Estado_dual) {
    digitalWrite(led_02, HIGH);
  }
  else {
    digitalWrite(led_02, LOW);
  }
}

void Funcion_bt2(void *ptr) {
  uint32_t Estado_dual;/* Consigo el valor del estado del componente. */
  bt2.getValue(&Estado_dual);

  if (Estado_dual) {
    digitalWrite(led_03, HIGH);
  }
  else {
    digitalWrite(led_03, LOW);
  }
}

void Funcion_bt3(void *ptr) {
  uint32_t Estado_dual;/* Consigo el valor del estado del componente. */
  bt3.getValue(&Estado_dual);

  if (Estado_dual) {
    digitalWrite(led_04, HIGH);
  }
  else {
    digitalWrite(led_04, LOW);
  }
}

void Funcion_bt4(void *ptr) {
  uint32_t Estado_dual;/* Consigo el valor del estado del componente. */
  bt4.getValue(&Estado_dual);

  if (Estado_dual) {
    digitalWrite(led_05, HIGH);
  }
  else {
    digitalWrite(led_05, LOW);
  }
}

void Funcion_bt5(void *ptr) {
  uint32_t Estado_dual;/* Consigo el valor del estado del componente. */
  bt5.getValue(&Estado_dual);

  if (Estado_dual) {
    digitalWrite(led_06, HIGH);
  }
  else {
    digitalWrite(led_06, LOW);
  }
}

void Funcion_bt6(void *ptr)
{ uint32_t Estado_dual;/* Consigo el valor del estado del componente. */
  bt6.getValue(&Estado_dual);
  
  while (1) {

    digitalWrite(led_01, LOW);
    digitalWrite(led_02, HIGH);
    digitalWrite(led_03, LOW);
    digitalWrite(led_04, HIGH);
    digitalWrite(led_05, LOW);
    digitalWrite(led_06, LOW);
    delay (500);
    digitalWrite(led_01, HIGH);
    digitalWrite(led_02, LOW);
    digitalWrite(led_03, LOW);
    digitalWrite(led_04, LOW);
    digitalWrite(led_05, HIGH);
    digitalWrite(led_06, HIGH);
    delay (500);
    digitalWrite(led_01, HIGH);
    digitalWrite(led_02, LOW);
    digitalWrite(led_03, HIGH);
    digitalWrite(led_04, LOW);
    digitalWrite(led_05, LOW);
    digitalWrite(led_06, LOW);
    delay(500);
    }
  }

Hello nguyenhieu0209,
Welcome.

Please read How to use this forum
Especially item #7 on posting code, the go back and edit the code in your post to include code tags </> as per the instructions.

Support for Nextion on these fora is pretty much as follows:
You can follow the methods I set out in using Nextion displays with Arduino. My methods do not use the Nextion libraries, so while I am happy to offer help on using my methods I cannot offer anything very helpful for any Nextion library.
The original Nextion libraries are full of bugs. There is a link from my tutorial to some improved Nextion libraries created by Ray Livingston, I suggest those might be worth trying if you prefer to use a library.
There's also a separate Easy Nextion Library by Seithan, his methods are different to mine, choose which works best for you.
Beyond that the odd person occasionally offers a bit of help but not much.

That said here is the limited help I can offer:

You say you are using a Uno, a Uno only has 1 serial port, which is already in use for the serial monitor. Because there is no spare serial port you either have to use software serial or connect the Nextion to the same serial port used by the serial monitor, this does work sort of, but there are limitations. I don't know how well it works with the Nextion library, if at all.

I can't see anywhere in your code that you initialise either the hardware serial port or a software serial port, which means your code is not talking to the Nextion.

You have not said how you have connected the Nextion to the Uno.

It is your intention for your code to get stuck here?

  while (1) {
    digitalWrite(led_01, LOW);
    digitalWrite(led_02, HIGH);
    digitalWrite(led_03, LOW);
    digitalWrite(led_04, HIGH);
    digitalWrite(led_05, LOW);
    digitalWrite(led_06, LOW);
    delay (500);
    digitalWrite(led_01, HIGH);
    digitalWrite(led_02, LOW);
    digitalWrite(led_03, LOW);
    digitalWrite(led_04, LOW);
    digitalWrite(led_05, HIGH);
    digitalWrite(led_06, HIGH);
    delay (500);
    digitalWrite(led_01, HIGH);
    digitalWrite(led_02, LOW);
    digitalWrite(led_03, HIGH);
    digitalWrite(led_04, LOW);
    digitalWrite(led_05, LOW);
    digitalWrite(led_06, LOW);
    delay(500);
    }

Because once it gets to the while(1) it will be stuck there forever, with the LEDs flashing on and off every half second, is that what you want to happen?

I don't think I can help you beyond that.

Thank you for reading my post. currently I cannot continue with the DSbutton bt6 function thanks to pro that can help me pass this function as my above purpose. Thanks for reading