Transferred from: http://www.geek-workshop.com/forum.php?mod=viewthread&tid=3383&highlight=12864
Many people when playing 12864 , will find that can not directly display characters, because most of the 12864 class library does not display the value of the function, then we need to convert the int variable into a string, the method is simple, as long as the code at the end of a function function can ~
char* itostr (int i) { "%d"return str;}
Put the above code at the end of the program, the program header defines a char a[25], after reading the value can be easily itostr (A, B), to convert, where a is the previously defined char,b is a numeric variable, is not very convenient?
======================================
Attach a double to string.
voidSetup () {//Put your setup code here, to run once:Double test = 1.23; Char test2[]; Dtostr (test2,test);} void Loop () { // put your main code here, to run repeatedly: } char* dtostr (char *str,
double
D) {sprintf (str, "%f", D); return str;}
Arduino:int & Double turn string for 12864 use