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!