I am trying to check whether the input string in my serial is inside my string array, but it seems like that the condition if(array[i]==inputString) does not print true.
So here is my code:
String array[4]={"hey","jude","jane"},inputString,test;
boolean stringComplete=false;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
//int store=0;
serialEvent();
if(stringComplete){
Serial.println(inputString);
for(int i=0;i<4;i++){
Serial.println("..");
//test=array[i];
Serial.println(array[i]);
if(inputString==array[i]){
Serial.println("true");
break;
}
}
inputString="";
stringComplete=false;
}
//Serial.println(store);
}
void serialEvent() {
while (Serial.available()) {
char inChar = (char)Serial.read();
inputString += inChar;
if (inChar == '\n') {
stringComplete = true;
}
}
}