I am trying to use an Arduino Mega 2560 variable to change font and pco on Nextion TJC4832T035_011.
Using the direct mySerial.write both font and pco change correctly however but when I try to use
the sprintf code in Arduino no changes occur on the Nextion.
It would appear that I have a problem with the format of my sprint code, can anyone help please?
Why in the world are you using software serial on a Mega. There are 3 extra hardware serial ports on the Mega. Besides the fact that SoftwareSerial will not work on pins 16 and 17.
Not all pins on the Mega and Mega 2560 support change interrupts, so only the following can be used for RX: 10, 11, 12, 13, 14, 15, 50, 51, 52, 53, A8 (62), A9 (63), A10 (64), A11 (65), A12 (66), A13 (67), A14 (68), A15 (69).
Thank you for your responses.
David 2018
Thanks I cannot believe I missed that.
Added MySerial.print(message); to the code
and it works. Much Appreciated
groundFungus. Pins 16 and 17 work just fine on the mega but I would prefer to use the built in
extra Serial ports on the Mega.
How do you set up these ports to use them.
Say I want to use Serial port 2. Do i just have to define the Tx & Rx pins as in SerialSoftware and then use "Serial2.print " instead of " mySerial.print"??
No, the pins for each serial port are fixed, you do not need to and cannot define them. To use serial port 2 you would put "Serial2.begin(115200);" (or a baud rate of your choice) in setup() and use Serial2.print() as you suggested.
Der Sketch verwendet 2978 Bytes (9%) des Programmspeicherplatzes. Das Maximum sind 30720 Bytes.
Globale Variablen verwenden 216 Bytes (10%) des dynamischen Speichers, 1832 Bytes für lokale Variablen verbleiben. Das Maximum sind 2048 Bytes.
Der Sketch verwendet 1732 Bytes (5%) des Programmspeicherplatzes. Das Maximum sind 30720 Bytes.
Globale Variablen verwenden 184 Bytes (8%) des dynamischen Speichers, 1864 Bytes für lokale Variablen verbleiben. Das Maximum sind 2048 Bytes.
Look at the massive size increase caused by using sprintf.