I am executing a function in Arduino by giving String input to the serial monitor.
The issue here is when iI enter "SHOW$" (without quotes)SHOW$, the function showData()showData() works but when iI enter the same "SHOW$" (without quotes)SHOW$, it doesn't gets called.
I want to call the function showData()showData() every time i enter the "SHOW$"SHOW$ text into the serial console.
My question here is to what mistake iI 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");
}