Char

From Microduino Wiki
Jump to: navigation, search

char

  • Description

It is a data type, which occupy a byte of memory to store a char value. The characters are all written in the single quotation marks, for example, 'A'(for multiple characters(character string)use double quotation marks, for example “ABC”).

Characters are stored in the form of numbers. You can find the corresponding code in ASCII code table, which means the ASCII codes of characters can be used a mathematical calculation(for example, 'A'+ 1, because ASCII value of the capital A is 65, the result is 66). As for how to change characters into numbers, please refer to command serial.println.

Char data type is signed type, which means its code is from -128 to 127. For an unsigned one-byte(8 bits) data type, byte type is suitable.
Example

  char myChar = 'A';
  char myChar = 65;      // both are equivalent


[Return to Arduino Syntax Manual]