How to convert int to string on Arduino?

前端 未结 9 1345
-上瘾入骨i
-上瘾入骨i 2021-01-31 06:32

How do I convert an int, n, to a string so that when I send it over the serial, it is sent as a string?

This is what I have so far:

int ledP         


        
9条回答
  •  余生分开走
    2021-01-31 07:23

    use the itoa() function included in stdlib.h

    char buffer[7];         //the ASCII of the integer will be stored in this char array
    itoa(-31596,buffer,10); //(integer, yourBuffer, base)
    

提交回复
热议问题