arduino xor checksum

#include <Arduino.h>

// Function to calculate XOR checksum
uint8_t calculateXORChecksum(const uint8_t* data, size_t length) {
  uint8_t checksum = 0;

  for (size_t i = 0; i < length; ++i) {
    checksum ^= data[i];
  }

  return checksum;
}

void setup() {
  // Your setup code here
}

void loop() {
  // Your main code here

  // Example of using the calculateXORChecksum function
  uint8_t data[] = {0x01, 0x02, 0x03, 0x04, 0x05};
  size_t length = sizeof(data) / sizeof(data[0]);

  uint8_t checksum = calculateXORChecksum(data, length);

  // Use the calculated checksum as needed
  // ...

  // Optional delay or other loop operations
}