In this article, I wrote to you an example of how to easily convert a decimal into a char array on Arduino. To convert a decimal number to a char array in Arduino, you can use the
itoa() function. Here’s an example:
int num = 123; char charArray; itoa(num, charArray, 10); // 10 is the base Serial.println(charArray); // prints "123"
In this example,
itoa() the function takes three arguments: the decimal number you want to convert (
num), the char array where you want to store the result (
charArray), and the base you want to use for the conversion (in this case, 10 for decimal).
charArray will contain the converted number as a sequence of characters. Note that the
charArray must have enough space to store the converted number plus a null terminator character (
You can then print the
Serial.println() or use it in other ways as needed.
- Arduino Convert Float To Char Array
- Convert Data Type Arduino Serial Monitor
- Arduino Float to String Convert Tutorial