Analyze if a char is a digit (that is a number). Returns true if the input char is a number.
Use the following function to evaluate a char variable:
isDigit(thisChar)
The function admits the following parameter:
thisChar: char variable to evaluate. Allowed data types: char.
The function returns true if the evaluated input variable is a number.
char myChar = '8'; // try with 'n' for a non numerical char
void setup() {
Serial.begin(9600);
if (isDigit(myChar)) { // tests if myChar is a digit
Serial.println("The character is a number");
}
else {
Serial.println("The character is not a number");
}
}
void loop() {
}