Arduino:int & Double Turn string suitable for 12864 use

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.