Hello There ,
I implementing code example 2 of this link Example 2
and I modified those code to study strcmp like bellow :
// Example 2 - Receive with an end-marker
const byte numChars = 32;
char receivedChars[numChars]; // an array to store the received data
boolean newData = false;
void setup() {
Serial.begin(9600);
Serial.println("<Arduino is ready>");
}
void loop() {
recvWithEndMarker();
showNewData();
}
void recvWithEndMarker() {
static byte ndx = 0;
char endMarker = '\n';
char rc;
while (Serial.available() > 0 && newData == false) {
rc = Serial.read();
if (rc != endMarker) {
receivedChars[ndx] = rc;
ndx++;
if (ndx >= numChars) {
ndx = numChars - 1;
}
}
else {
receivedChars[ndx] = '\0'; // terminate the string
ndx = 0;
newData = true;
}
}
}
void showNewData() {
if (newData == true) {
if(strcmp(receivedChars, "123") == 0){
Serial.println("Your chois is Right");
}
else {
Serial.println("Your chois not good");
}
Serial.println(receivedChars);
newData = false;
}
}
but the result is always FALSE ("Your chois not good") Please See Attachment
I do not understand how to compare using strcmp in the right ways
Please HELP what is wrong in my code
Thanks

