// FILE: luhn_check.ino // AUTHOR: Rob Tillaart // DATE: 2022-12-24 // PURPOSE: demo // URL: https://github.com/RobTillaart/LUHN #include "Arduino.h" #include "LUHN.h" uint32_t start, stop; LUHN checker; // example https://en.wikipedia.org/wiki/Luhn_algorithm char cardNumber[20] = "79927398713"; void setup() { Serial.begin(115200); while (!Serial); Serial.println(); Serial.println(__FILE__); // SHOULD PRINT 3 Serial.println(checker.generateChecksum((char *)"7992739871")); } void loop() { char buffer[50] = ""; int len = 0; Serial.println("give string"); while (buffer[len - 1] != '\n') { if (Serial.available()) { buffer[len++] = Serial.read(); buffer[len] = '\0'; } } Serial.print(buffer); Serial.print(" ==> "); Serial.println(checker.generateChecksum(buffer)); } // -- END OF FILE --