Arduino: Float to String - Here's how
It often happens when programming with the Arduino that you have to convert a float to a string. You can find out how to do this in this practical tip.
Arduino: Float to String - Here's how
In the following instructions, we assume that you have already defined a float variable. You can do this with the command »float test = 12.4;«.
- To convert this variable into a string, you need a new string variable. You can define this, for example, with the »String test2;« command.
- To assign the string of the float to the string variable, only the command »test2 = String (test);« has to be executed.
- So you can easily convert floating point numbers into character strings and display them on a display, for example.
In the next practical tip we will show you how you can control LEDs with the Arduino.