Start a new topic

setText string

I have read the forum post here

http://support.iteadstudio.com/support/discussions/topics/11000012636/page/5?url_locale=

but I am a little unsure of how to implement it on the arduino. 


I have an array of names stored on the arduino


User_Array [1] = Harry

User_Array [2] = Fred

User_Array [3] = Bob

etc


Depending on what is selected I want to set the value of a variable on the nextion screen, so that I can then write it into a text field, to be one of these names


if (x = 1)

{

Nextion_Variable.setText(User_Array[1]);

}

if (x = 2)

{

Nextion_Variable.setText(User_Array[2]);

}

if (x = 3)

{

Nextion_Variable.setText(User_Array[3]);

}



but when I try to send to the Nextion I get the variable being set to a number.


I have tried to add the quotation marks required, but this does not seem to work either.


  char copy[20];

 

  String blah = "\"Blah\"";

  blah.toCharArray(copy,20);

  Serial.println(copy);

  memset(buffer, 0, sizeof(buffer)); // clear buffer

  itoa(copy, buffer, 10);

  Name.setText(buffer);


If however I type in

 

Name.setText("Harry");


it works perfectly so I have got the comms working so it must be something I am doing wrong on the arduino side.


Then

  since Indev2 gave a good answer to my modified example

  and since issue is what you are doing wrong on your Arduino mcu side

Isn't this an Arduino question or more Arduino required research?

I just thought someone could help explain it in a little simpler terms so I could learn from it.