Hi,
So I tried the basic example from the easy nextion library but this doesn’t work
#include “EasyNextionLibrary.h” // Include EasyNextionLibrary
EasyNex myNex(Serial); // Create an object of EasyNex class with the name < myNex >
// Set as parameter the Hardware Serial you are going to use
void setup(){
myNex.begin(9600); // Begin the object with a baud rate of 9600
// If no parameter was given in the begin(), the default baud rate of 9600 will be used
pinMode(LED_BUILTIN, OUTPUT); // The built-in LED is initialized as an output
}
void loop(){
myNex.NextionListen(); // This function must be called repeatedly to response touch events
// from Nextion touch panel. Actually, you should place it in your loop function.
}
void trigger0(){
/* Create a button on Nextion
-
Write in the Touch Release Event of the button
-
this command: printh 23 02 54 00
-
Every time the button is pressed, the trigger0() function will run
-
and the code inside will be executed once
*/
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN)); //If LED_BUILTIN is ON, turn it OFF, or the opposite
if(digitalRead(LED_BUILTIN) == HIGH){
myNex.writeNum(“b0.bco”, 2016); // Set button b0 background color to GREEN (color code: 2016)
myNex.writeStr(“b0.txt”, “ON”); // Set button b0 text to “ON”
}else if(digitalRead(LED_BUILTIN) == LOW){
myNex.writeNum(“b0.bco”, 63488); // Set button b0 background color to RED (color code: 63488)
myNex.writeStr(“b0.txt”, “OFF”); // Set button b0 text to “ON”
}
}