How to Use isControl() in Arduino?

ArduinoHardwareSoftware & Coding

The isControl() function is used to determine if a character is a control character. A control character or a non-printing character (NPC) is a code point (a number) in a character set that does not represent a written symbol. All entries in the ASCII table below code 32 are of this kind. This includes characters like '\n', '\t', and so on.


The syntax of the isControl function is as follows −


Where myChar is the character being evaluated. If it is a control character, this function returns True, otherwise False.


The following example illustrates how to use this function −

void setup() {
   char c1 = 'a';
   char c2 = '\n';
   if (isControl(c1)) {
      Serial.println("c1 is a control char");
   } else {
      Serial.println("c1 is NOT a control char");
   if (isControl(c2)) {
      Serial.println("c2 is a control char");
   } else {
      Serial.println("c2 is NOT a control char");
void loop() {


The Serial Monitor output is shown below −

Updated on 24-Jul-2021 14:02:04