Hello Friends , How are you today?
i am here to ask you about my problem and i hope you will help me back for doing my project fastly ,
i am working on the nextion screen interfacing with the arduino uno , i have seen a multiple tutorial about it , finally i understand how it works , but i have one more issues , in the code below , it can reads one text from the nextion screen , till now everything worked well , but my problem is if i want to read more than one text(2 or three or n text), i have wrote same as this code but with another char (character) , for example char a , but when i write Serial.println , after compiling , i cannot see more than one character or more than one text on the arduino monitor , i will explain more , assume i have two text on my nextion screen , if i write my code to read only one , then print it on the arduino monitor , it worked well , when i add another char to read the second text , it will not show me the second text on the monitor of arduino.
now i will post the original code here,and i hope i can solve this problem quikly for my projectš¢
note : when you see the"//", that's mean this is my additional code , but it is not working
#include <doxygen.h>
#include <NexButton.h>
#include <NexCheckbox.h>
#include <NexConfig.h>
#include <NexCrop.h>
#include <NexDualStateButton.h>
#include <NexGauge.h>
#include <NexGpio.h>
#include <NexHardware.h>
#include <NexHotspot.h>
#include <NexNumber.h>
#include <NexObject.h>
#include <NexPage.h>
#include <NexPicture.h>
#include <NexProgressBar.h>
#include <NexRadio.h>
#include <NexRtc.h>
#include <NexScrolltext.h>
#include <NexSlider.h>
#include <NexText.h>
#include <NexTimer.h>
#include <Nextion.h>
#include <NexTouch.h>
#include <NexUpload.h>
#include <NexVariable.h>
#include <NexWaveform.h>
NexButton b0 = NexButton(0, 1, "b0"); // Button added
NexPage page0 = NexPage(0, 0, "page0"); // Page added as a touch event
NexText t0 = NexText(0, 2, "t0"); // Text box added, so we can read it
//NexText t1 = NexText(0, 3, "t1"); // Text box added, so we can read it//hon
char buffer[100] = {0};
//char yy[100]={0};//hon
NexTouch *nex_listen_list[] =
{
&b0, // Button added
&page0, // Page added as a touch event
NULL // String terminated
}; // End of touch event list
void b0PushCallback(void *ptr) // Press event for button b1
{
digitalWrite(13, LOW); // Turn ON internal LED
} // End of press event
void b0PopCallback(void *ptr) // Release event for button b1
{
digitalWrite(13, HIGH); // Turn OFF internal LED
memset(buffer, 0, sizeof(buffer)); // Clear the buffer, so we can start using it
t0.getText(buffer, sizeof(buffer)); // Read the text on the object t5 and store it on the buffer
// memset(yy, 0, sizeof(yy));
// t1.getText(yy, sizeof(yy));//hon
} // End of release event
void setup() {
// put your setup code here, to run once:
Serial.begin(9600); // Start serial comunication at baud=9600
// I am going to change the Serial baud to a faster rate.
// The reason is that the slider have a glitch when we try to read it's value.
// One way to solve it was to increase the speed of the serial port.
delay(500); // This dalay is just in case the nextion display didn't start yet, to be sure it will receive the following command.
Serial.print("baud=115200"); // Set new baud rate of nextion to 115200, but it's temporal. Next time nextion is power on,
// it will retore to default baud of 9600.
// To take effect, make sure to reboot the arduino (reseting arduino is not enough).
// If you want to change the default baud, send the command as "bauds=115200", instead of "baud=115200".
// If you change the default baud, everytime the nextion is power ON is going to have that baud rate, and
// would not be necessery to set the baud on the setup anymore.
Serial.write(0xff); // We always have to send this three lines after each command sent to nextion.
Serial.write(0xff);
Serial.write(0xff);
Serial.end(); // End the serial comunication of baud=9600
Serial.begin(115200); // Start serial comunication at baud=115200
b0.attachPush(b0PushCallback); // Button press
b0.attachPop(b0PopCallback); // Button release
}
void loop() {
// put your main code here, to run repeatedly:
Serial.print(buffer);
// Serial.print(yy);//yy
nexLoop(nex_listen_list);
}