Arduino Int to Char

Ammar Ali Apr 29, 2021 Apr 04, 2021 Arduino Arduino Integer
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.

Author: Ammar Ali
Ammar Ali avatar Ammar Ali avatar

Hello! I am Ammar Ali, a programmer here to learn from experience, people, and docs, and create interesting and useful programming content. I mostly create content about Python, Matlab, and Microcontrollers like Arduino and PIC.

LinkedIn Facebook

Related Article - Arduino Integer

  • Arduino Char to Int
  • Convert Integer to String in Arduino