Text string

String of text may show to any string information on smartphone screen. This may be the actual value of a parameter or condition controller. If you use text, you must specify the length, in bytes, of the structure RemoteXY will be allocated a buffer of a given length. Line of text must be terminated by zero. Do not exceed the specified length of the variable selected for the text.


Display textchar[x]display text, for text length x bytes


  • Variable name - name of the text and the variable in the source code for the microcontroller, allow to set a name for the variable of C rules.
  • Length - The number of characters allotted for a string variable. By the size of the text buffer is automatically added to a single byte for the terminating zero.

Code example

To pass a string of text that you want this string to be inserted in the appropriate field patterns RemoteXY. String according to the C rules, zero-terminated. You can use different designs for the formation of a string field.

The immediate setting an arbitrary string:

  strcpy  (RemoteXY.text_1, "My text");
  sprintf (RemoteXY.text_2, "My text");

The string that is copied from another string:

  char str[] = "My text";
  strcpy  (RemoteXY.text_1, str);
  sprintf (RemoteXY.text_2, str);
  sprintf (RemoteXY.text_3, "%s", str);

Function sprintf(charBuf, format, ...) allows you to use the formatted string to represent the string data:

  char str[] = "Value";
  int val = 1234;
  sprintf (RemoteXY.text_3, "%s is %d", str, val); // result: "Value is 1234"

Unfortunately the Arduino function sprintf does not recognize the format string to a floating-point number %f. In exchange for this you can use the function
dtostrf (floatVar, minStringWidthIncDecimalPoint, numVarsAfterDecimal, charBuf):

  double val = 1234.321;
  dtostrf(val, 0, 2, RemoteXY.text_1); // result: "1234.32"

To convert an integer to a string so you can use the function itoa ():

  int val = 1234;
  itoa (val, RemoteXY.text_1, 10);

The following example shows how to display the textual representation of the state of the input pin 4, for Arduino::

  if (digitalRead(4)==HIGH) strcpy (RemoteXY.text_1, "High");
  else strcpy (RemoteXY.text_1, "Low");

The following example shows how to display the voltage on the analogue input A0, for Arduino:

  // ADC is equal to 204.8 on volts when the supply voltage is 5 Volts
  double val = analogRead(A0) / 204.8; 
  dtostrf(val, 0, 2, RemoteXY.text_1);