esplora LCD tft is driving me nuts.

I cannot get tekst on my screen using variables. I am now trying to sent something via the serial monitor and print that, the code looked as follows,

{
char c;
String tekst = ""; // initialises empty string every time
String old_tekst;
if (Serial.available()) { // when i send message
delay(10); // wait for message to get in the buffer before proceeding
while(Serial.available()){
Len = Serial.available(); // will be the length for the buffer in the following code

c = Serial.read(); // read a byte as char
tekst += c; // adds the char to the empty string
}
char buf[Len]; // declare character array with size 'Len'
tekst.toCharArray(buf,Len); // Esplora.tft.text() just won't accept String object, so I go back to character array

EsploraTFT.stroke(100,100,100);
EsploraTFT.text(buf,10,10); // print the bloody message

}

if I try EsploraTFT.text(String whatever,10,10); I get error for using String.
if I try char message[11] = 'hello world'; EsploraTFT.text(message, 10, 10) im getting a random character printed.
if I try EsploraTFT.text("hello world", 10, 10); it works but it is not variabele and thus useless.

So how do I get a variable with a tekst message get printed

What error are you getting for using String? There's probably a hint in there somewhere.

if I try char message[11] = 'hello world'; EsploraTFT.text(message, 10, 10) im getting a random character printed.
if I try EsploraTFT.text("hello world", 10, 10); it works but it is not variabele and thus useless.

Is it really a random character?

Maybe try

char message[11] = "hello world";  //double quotes for more than one character
EsploraTFT.text(message, 10, 10);

y this: char test[12] = “hello world”; works, it is strange I have to fill in 12 for the index instead of 11 but it works… many tnx

and this:
String test2 = “hello world”;
EsploraTft.text(test2, 10, 10); // gives following error message

C:\Program Files\Arduino\libraries\TFT\src/utility/Adafruit_GFX.h:174:2: note: no known conversion for argument 1 from ‘String’ to ‘const char*’
I think this means something like: EsploraTft.text(); does not like it to print String, so scr*w you and plz try again :smiley:

O O I spotted the error… in

if (Serial.available()) {
delay(10); << here message has time to reach buffer
while(Serial.available()){
Len = Serial.available(); << ment to get the ammount of bytes, problem is this number gets lower every time the code runs thru the while loop until it eventually reaches 0.

c = Serial.read();
tekst += c;
}
char buf[Len];
tekst.toCharArray(buf,Len);

problem fixed:

if (Serial.available()) {
delay(10);
while (Serial.available()) {

if (var == 1) {
Len = Serial.available() + 1; << here is em fix, preformed one time only
var = 0;
}

char c = Serial.read();
tekst += c;
}
char buf[Len];
tekst.toCharArray(buf, Len);