I am executing a function in Arduino by giving String input to the serial monitor.
The issue here is when I enter SHOW$, the function showData() works but when I enter the same SHOW$, it doesn't gets called.
I want to call the function showData() every time i enter the SHOW$ text into the serial console.
My question here is to what mistake I am doing here, and what is the solution for this.
String strReq = "";
char inChar = 0;
void setup() {
Serial.begin(9600);
}
void loop() {
while (Serial.available())
{
inChar = Serial.read();
if (inChar == '$') {
Serial.println(" Received String :");
Serial.print(strReq);
if (strReq.equalsIgnoreCase("SHOW"))
showData();
Serial.flush();
strReq = "";
} else {
strReq = strReq + inChar;
}
}
}
void showData() {
Serial.print("Showing Information");
}
else if (inChar >= 32) {