if((input[0] ^ input[2] ^ input[4] ^ input[6] ^ input[8] == input[10]) &&
(input[1] ^ input[3] ^ input[5] ^ input[7] ^ input[9] == input[11]))
Serial.println("No Error");
else
Serial.println("Error");
Pleae explain
if((input[0] ^ input[2] ^ input[4] ^ input[6] ^ input[8] == input[10]) &&
(input[1] ^ input[3] ^ input[5] ^ input[7] ^ input[9] == input[11]))
Serial.println("No Error");
else
Serial.println("Error");
Pleae explain
Because you want us to do your homework for you.
( Wrong forum section. Please exp!ain)
Seems pretty simple. If the if statement is true it prints “No Error” otherwise it prints “Error”.
All the operators are detailed in the Arduino Reference, look at the top of the page under Resources.
Steve
Looks like the array contains two checksums, calculated by bitwise XOR ing (^) bytes 0, 2, 4, 6, and 8 and bytes 1,3,5,7 and 9 - with the checksum bytes being byte 10 and 11.
Checksumming using XOR is very common - it's done when you think there's a possibility that the data could get mangled in transmission, and need to avoid using that bad data. So you have the thing sending it include a checksum that you can check it against to verify that the data is correct on the receiving side.