Dear All,
I'm trying to calculate the check sum in this array , the result should be D3 but when i'm getting different values .
the sum will be calculated from the whole package's single bytes in the array, the checksum value in position array[3], and by checking the value i will know if i have correct or wrong message.
char array[36]= {00,0x24,00,0xD3,01,00,00,00,01,00,00,00,01,00,00,00,01,00,00,00,01,00,00,00,01,00,00,00,01,00,00,00,01,00,00,00};
char checksum ;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println();
}
void loop() {
char sum = 0;
for (int i = 0; i < 36; i++) {
sum += array[i];
}
checksum = 0xff- sum ;
Serial.println(checksum);
}