I am trying to send T0.txt="Down" into the serial port3. Is this code correct.
Serial3.print("t0.txt=");
Serial3.write(34);
Serial3.print("Down");
Serial3.write(34);
Serial3.println("");
This doesn't work.
I am trying to send T0.txt="Down" into the serial port3. Is this code correct.
Serial3.print("t0.txt=");
Serial3.write(34);
Serial3.print("Down");
Serial3.write(34);
Serial3.println("");
This doesn't work.
You need to escape the " using a \ like this
Serial3.print("t0.txt=");
Serial3.println("\"Down\"");
This doesn’t work.
Whatever that means
Try..
Serial.println("T0.txt=\"Down\"");
-jim lee
I didn't see anything wrong with your snippet. I ran this on my Mega:
void setup()
{
Serial.begin(115200);
Serial.print("t0.txt=");
Serial.write(34);
Serial.print("Down");
Serial.write(34);
Serial.println("");
}//setup
void loop()
{
}//loop
and got this in the serial monitor:
t0.txt="Down"
Are you sure the error lies in your code and not in whatever is receiving this message?
Looks like a message to a Nextion display to me, see my tutorial using Nextion displays with Arduino at the top of the display section of the forum, plenty of examples in there of what you are doing.
PerryBebbington:
Looks like a message to a Nextion display to me,
I second that. So the culprit is
Serial.println("");
You don't want to send a CR/LF, you have to send three 0xFF.
Serial.write(0xFF);
Serial.write(0xFF);
Serial.write(0xFF);
Blackfin:
I didn't see anything wrong with your snippet. I ran this on my Mega:void setup()
{
Serial.begin(115200);
Serial.print("t0.txt=");
Serial.write(34);
Serial.print("Down");
Serial.write(34);
Serial.println("");
}//setup
void loop()
{
}//loop
and got this in the serial monitor:
t0.txt="Down"
Are you sure the error lies in your code and not in whatever is receiving this message?
Yes. The real problem were those missing three 0xffs. Thank you all.
Edit: Nextion is new to me and when Debugger /simulator worked without 0xFFs, I didn't immediately add them my code.
Always use the Serial.print() and not the Serial.println() for the Nextion display.
The three 0xFF can be put in a text as well.
Serial.print( "T0.txt=\"Down\"\xFF\xFF\xFF");
The Debugger/Simulator of the Nextion editor ? How did you connect that to an Arduino board ?
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.