Issues with the isAlphaNumeric(thisChar) function!


In the Reference is said this about the isAlphaNumeric(thisChar):

Analyse if a char is alphanumeric.

However the given example uses an integer:

void setup() {
  // Open serial communications and wait for port to open:
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only

  // send an intro:
  Serial.println("send any byte and I'll tell you everything I can about it");

void loop() {
  // get any incoming bytes:
  if (Serial.available() > 0) {
    int thisChar =;

    // say what was sent:
    Serial.print("You sent me: \'");
    Serial.print("\'  ASCII Value: ");

    // analyze what was sent:
    if (isAlphaNumeric(thisChar)) {
      Serial.println("it's alphanumeric");
    if (isAlpha(thisChar)) {
      Serial.println("it's alphabetic");
    if (isAscii(thisChar)) {
      Serial.println("it's ASCII");
    if (isWhitespace(thisChar)) {
      Serial.println("it's whitespace");
    if (isControl(thisChar)) {
      Serial.println("it's a control character");
    if (isDigit(thisChar)) {
      Serial.println("it's a numeric digit");
    if (isGraph(thisChar)) {
      Serial.println("it's a printable character that's not whitespace");
    if (isLowerCase(thisChar)) {
      Serial.println("it's lower case");
    if (isPrintable(thisChar)) {
      Serial.println("it's printable");
    if (isPunct(thisChar)) {
      Serial.println("it's punctuation");
    if (isSpace(thisChar)) {
      Serial.println("it's a space character");
    if (isUpperCase(thisChar)) {
      Serial.println("it's upper case");
    if (isHexadecimalDigit(thisChar)) {
      Serial.println("it's a valid hexadecimaldigit (i.e. 0 - 9, a - F, or A - F)");

    // add some space and ask for another byte:
    Serial.println("Give me another byte:");

Why I can't use a String, and how to check if a String is a Alphanumeric?

Why I can’t use a String

Imagine your String is “A_2”.
What should isAlphaNumeric return?

Imagine your String is "A_2".
What should isAlphaNumeric return?

FALSE, like in the Excel function =ISNUMBER (value)! :slight_smile:

A String is not a character.

It is meaningless to use a function that expects a character to analyze a String. Garbage IN = Garbage OUT.

The example is a bad one, because of the peculiarities of the Arduino function.