Nextion Dual State Button I am having an issue with my Nextion display. I have uploaded the following code via Arduino IDE to my Arduino MEGA 2560.
My Nextion Editor shows the button as ID:9 on page0 named floor. I am not entirely sure if the code below is correct. I had one issue where the upload from the laptop to the Mega wouldn't finish, but I managed to bypass that issue by disconnecting the Nextion and swapping RX and TX cables from Nextion while the upload was in progress. Not sure how else I would fix that issue? (If anyone has any ideas haha)
All that is meant to happen is when the dual button state is changed, the onboard LED_BUILTIN is set to HIGH and if in its second state, is set to LOW.
CODE
#include &quot;Nextion.h&quot;


NexDSButton bt0 = NexDSButton(0, 9, &quot;floor&quot;);


int ledPin = LED_BUILTIN;


char buffer[100] = {0};


NexTouch *nex_listen_list[] = 
{
    &amp;bt0,
    NULL
};



void bt0PopCallback(void *ptr)
{
    uint32_t dual_state;
    NexDSButton *btn = (NexDSButton *)ptr;
    dbSerialPrintln(&quot;b0PopCallback&quot;);
    dbSerialPrint(&quot;ptr=&quot;);
    dbSerialPrintln((uint32_t)ptr); 
    memset(buffer, 0, sizeof(buffer));

    if(dual_state) 
    {
        digitalWrite(ledPin, HIGH);
    }
    else
    {
        digitalWrite(ledPin, LOW);
    }
}

void setup(void)
{    
    nexInit();

    bt0.attachPop(bt0PopCallback, &amp;bt0);
    
    dbSerialPrintln(&quot;setup done&quot;); 
    pinMode(ledPin, OUTPUT);
}

void loop(void)
{   
    nexLoop(nex_listen_list);
}

My issue is that the MEGA is identifying the touch event (as the TX LED on the MEGA flashes) however it is not turning on the MEGA's onboard built-in LED.
Any help would be greatly appreciated!
This is part of the code I have been using for an extraction fan, The button text is tested and if the button matches the command the fan is turned on or off and the button text is changed accordingly. Hope this helps.

void b19PopCallback(void *ptr) //Extraction Fan
{
  NexButton *btn = (NexButton *)ptr;
  memset(buffer, 0, sizeof(buffer));
  btn-&gt;getText(buffer, sizeof(buffer));

  if (strcmp(buffer, "ON"))
  {
    //COMES BACK AS A FALSE (0) IF BOTH STRINGS MATCH
    digitalWrite(b_motor, LOW);
    strcpy(buffer, "ON");
    btn-&gt;setText(buffer);
  }

  else 
  {
    digitalWrite(b_motor, HIGH);
    strcpy(buffer, "OFF");
    btn-&gt;setText(buffer);
  }  

}