736
Often when programming with the Arduino, it happens that you have to convert a float to string.
Arduino: Float to String – here’s how
In the following instructions, we assume that you have already defined a float variable. This can be done, for example, with the command “float floatvariable = 12.4;”.
- To assign the string of the float to the string variable, simply execute the command “String stringvariable = String(floatvariable);”
- Caution: String must be written with a capital initial letter in the declaration.
- This way you can easily convert floating point numbers into strings and output them on a display, for example.