LED Control with Nextion HMI

Hello there! I have an issue by trying to turn on and off an LED Diode. For some reason, the nextion HMI is not working, and the LED is not turning on.

I will drop my code here so you guys can help me check if there is an error on it that is not letting the LED turn on.

#include <Nextion.h>
const int led = 5;
NexButton b0 = NexButton (0,1,"b0");
NexButton b1 = NexButton(0,2,"b1");
NexText t0 = NexText(0,3,"t0");

NexTouch *nex_listen_list[]= {
&b0,
&b1,
NULL
};

void b0PopCallback(void *ptr){
t0.setText("STATE: ON");
digitalWrite(led,HIGH);

}

void b1PopCallback(void*ptr){
t0.setText("STATE: OFF");
digitalWrite(led, LOW);

}

void setup(void){
Serial.begin(9600);
nexInit();

b0.attachPop(b0PopCallback, &b0);
b1.attachPop(b1PopCallback, &b1);

pinMode(led, OUTPUT);
digitalWrite(led, LOW);

}

void loop(){
nexLoop(nex_listen_list);
}

Thank you much!

Your topic has been moved to a more suitable location on the forum. Please read the sticky topics in Uncategorized - Arduino Forum as to why you should not post in "Uncategorized".

Also please read How to get the best out of this forum and pay special attention to the section how to post code; next edit your post and apply the code tags.

I'm not familiar with Nextion so can't help further.

Hello @iter2001,

If you look at the top of the display category of the forum you will find my Nextion tutorial. If you are still struggling after reading it and trying out the sample code then I will try to help you.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.