Arduino Int to Char

This tutorial will discuss a method to convert an int to char using the assignment operator.

Convert int to char Using Assignment Operator in Arduino

A variable of type char will store the ASCII value of a given digit. For example, if you store an alphabet a in a variable of type char the variable will store the ASCII equivalent of the given alphabet, which is 97. If you use a print function to print the value of the variable of type char, it will not print the ASCII value; rather, it will print the ASCII equivalent character of the given variable. So if you want to convert a variable of type int into a variable of type char, the variable will be converted into its ASCII equivalent. For example, converting 97 into char, the result will be the alphabet a.

void loop(){
    int myInt = 97;
    char myChar = myInt;

In the above code, myInt is a variable of type int used to store the given number and myChar is a variable of type char used to store the result of the conversion.

DelftStack is a collective effort contributed by software geeks like you. If you like the article and would like to contribute to DelftStack by writing paid articles, you can check the write for us page.

Related Article - Arduino Integer

  • Convert Integer to String in Arduino