Skip to main content
added 134 characters in body
Source Link
KarmaCoding
  • 113
  • 1
  • 4
  • 15

I am very new to Arduino Programming. I am trying to identify the input string from serial monitor and printing the output to the console accordingly

Code is :

void setup() {
       Serial.begin(9600);
}

void loop() {

   while (Serial.available() > 0 ) {
    
     String str = Serial.readString();
     
     if (str.equals("send")) {
        Serial.println("identified");
     } else {
        Serial.println("unknown");
     }

   }

}

Whenever i put send string it is showing "unknown" as the output, which is wrong, and i should get "identified" as the output. Can anyone guide me here to achieve the result.

Note : I am getting output as i wanted by using readStringUntil function but the strings has a lot of "." in it, hence not useful.

I am very new to Arduino Programming. I am trying to identify the input string from serial monitor and printing the output to the console accordingly

Code is :

void setup() {
       Serial.begin(9600);
}

void loop() {

   while (Serial.available() > 0 ) {
    
     String str = Serial.readString();
     
     if (str.equals("send")) {
        Serial.println("identified");
     } else {
        Serial.println("unknown");
     }

   }

}

Whenever i put send string it is showing "unknown" as the output, which is wrong, and i should get "identified" as the output. Can anyone guide me here to achieve the result.

I am very new to Arduino Programming. I am trying to identify the input string from serial monitor and printing the output to the console accordingly

Code is :

void setup() {
       Serial.begin(9600);
}

void loop() {

   while (Serial.available() > 0 ) {
    
     String str = Serial.readString();
     
     if (str.equals("send")) {
        Serial.println("identified");
     } else {
        Serial.println("unknown");
     }

   }

}

Whenever i put send string it is showing "unknown" as the output, which is wrong, and i should get "identified" as the output. Can anyone guide me here to achieve the result.

Note : I am getting output as i wanted by using readStringUntil function but the strings has a lot of "." in it, hence not useful.

Source Link
KarmaCoding
  • 113
  • 1
  • 4
  • 15

Very Basic Arduino Uno Serial.readString() operation

I am very new to Arduino Programming. I am trying to identify the input string from serial monitor and printing the output to the console accordingly

Code is :

void setup() {
       Serial.begin(9600);
}

void loop() {

   while (Serial.available() > 0 ) {
    
     String str = Serial.readString();
     
     if (str.equals("send")) {
        Serial.println("identified");
     } else {
        Serial.println("unknown");
     }

   }

}

Whenever i put send string it is showing "unknown" as the output, which is wrong, and i should get "identified" as the output. Can anyone guide me here to achieve the result.