Nextion display 7inch NX8048T070 using led OFF ON

Hello, I am using a Nextion display 7inch NX8048T070 with Arduino UNO. I'm trying to on and off led light through the Nextion display led doesn't work till now.
And I've followed this tutorial

NEXTION HMI Display With Arduino–Getting Started | alselectro

I'm using this library also "GitHub - itead/ITEADLIB_Arduino_Nextion"
Code:


#include <Nextion.h>

const int led = 13;

//Declare your Nextion objects , pageid, component id., component name

NexButton b0 = NexButton(0,2,”b0″);
NexButton b1 = NexButton(0,3,”b1″);
NexText t0 = NexText(0,4,”t0″);

//Register a button object to the touch event list

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

//Button b0 component popcallback function
// When ON button is Released the LED turns ON and the state text changes

void b0PopCallback(void *ptr){
t0.setText (“State:ON”);
digitalWrite(led,HIGH);
}

//Button b1 component popcallback function
// When OFF button is released the LED turns OFF and the state text changes

void b1PopCallback(void *ptr){
t0.setText (“State:OFF”);
digitalWrite(led,LOW);
}
void setup(void) {
Serial.begin(9600);
nexInit();
//Register the pop event callback function of the components

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

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

}

void loop() {
nexLoop(nex_listen_list);

}

Hi, welcome to the forum.

Could you edit your post and change the category to "Displays" ?

What does work ?
I assume that you have uploaded the code to the Nextion display with the Nextion Editor.
Did you connect RX to TX and TX to RX ?
Which settings do you have in NexConfig.h for the serial port ?
Can you write a text to a text field ?

Most of us don't like that ITEADLIB_Arduino_Nextion library. If you are willing to try something else, then you can start here: https://forum.arduino.cc/t/using-nextion-displays-with-arduino/580289

Yes .. I'm going to connected Rx to Tx and Tx to Rx ....Vcc to 5V 1amp and GND
In NexConfig.h setting for Arduino UNO I'm going to comment lines 27 and 32 and edited 37 line :
nexconfig

I uploaded the TFT file (from Nextion Editor) through an SD card. After that, I'm going to upload this code :

#include <Nextion.h>

const int led = 13;

//Declare your Nextion objects , pageid, component id., component name

NexButton b0 = NexButton(0,2,”b0″);
NexButton b1 = NexButton(0,3,”b1″);
NexText t0 = NexText(0,4,”t0″);

//Register a button object to the touch event list

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

//Button b0 component popcallback function
// When ON button is Released the LED turns ON and the state text changes

void b0PopCallback(void *ptr){
t0.setText (“State:ON”);
digitalWrite(led,HIGH);
}

//Button b1 component popcallback function
// When OFF button is released the LED turns OFF and the state text changes

void b1PopCallback(void *ptr){
t0.setText (“State:OFF”);
digitalWrite(led,LOW);
}
void setup(void) {
Serial.begin(9600);
nexInit();
//Register the pop event callback function of the components

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

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

}

void loop() {
nexLoop(nex_listen_list);

}

By using "Serial" on a Arduino Uno, you gave up the Serial Monitor, which would be very useful to show (debug) messages.

With a Arduino Leonardo, there is a spare hardware Serial port for the Nextion display.
With a Arduino Uno, some add a Serial port with SoftwareSerial. I have a Uno with a AltSoftSerial port for the Nextion display.

Can you send text to a text field ? For example "Hello" to 't0' ?

Can you try to change the forum Category ?

@pralaish, your topic has been moved to a more suitable location on the forum. Installation and Troubleshooting is not for problems with your project :wink: See About the Installation & Troubleshooting category.

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