Can we concatenate a variable and text in a single Serial.print() line ?

+4 votes
asked Feb 9, 2016 by mathieu-bertin (190 points)
retagged Feb 9, 2016 by remi-boulle

Hi !

Is it possible to concatenate a variable and text in a single Serial.print() line ?

Thank you !

1 Answer

+7 votes
answered Feb 9, 2016 by vincent-fougeras (580 points)
selected Feb 9, 2016 by mathieu-bertin
 
Best answer

This is possible by using the Serial.printf() function, just like a regular printf() function.
Here is an example :

int a = 12;
Serial.printf("a is equal to %d\n", a); /* Prints "a is equal to 12" */
commented Feb 9, 2016 by mathieu-bertin (190 points)
It works ! Thank you very much !!
commented Feb 10, 2016 by nigel-kozlwosky (130 points)
me2 ! :) Thanks
Welcome to OpenWiNo Q&A, where you can ask questions and receive answers from other members of the community.
To change your password you must follow THIS link.

24 questions

32 answers

18 comments

37 users

...