I've been working on a module to control my car over bluetooth, but I'm having trouble getting the Serial read input to.
I attached my code below, but here's a copy of my void loop and the variable declaration.
char character[100];
char rgb[][100] = {"Horn", "Remote Start", "Headlights", "Accessory", "Trunk", "Open sunroof", "Close sunroof",
"Dwindow up", "Dwindow down", "Pwindow up", "Pwindow down", "Lock",
"Unlock", "all lights", "Fades", "Strobe", "Halos", "Underbody Lights",
"Interior Lights"
};
if (Serial.available() > 0) {
while (Serial.available()) {
delay(20);
character[t] = Serial.read();
++t;
//red = Serial.parseInt();
//green = Serial.parseInt();
//blue = Serial.parseInt();
}
character[t] = '\0';
Serial.println(character);
for (i = 0; i < 19; i++) {
Serial.println(rgb[i]);
Serial.println(character);
int result = strcmp(character, rgb[i]);
if (result == 0) {
BCM(i);
break;
} else {
Serial.println("String's don't match");
}
}
}
Can someone help me figure out whats wrong with my code? It always skips to the else line after it compares the char array.
sketch_may01a.ino (13 KB)