This is some code that will help prevent most people from cloning your device and making money of something you spent time developing
See the code in action on Tinkercad
/*
Copyright() is an anti-piracy kill switch
Referrence http://ww1.microchip.com/downloads/en/DeviceDoc/40001906A.pdf
Page 322 Table 31-5. Signature Row Addressing
This demo
serialLength = 8 will be an Authentic Controller
serialLength = 9 will be a Pirated Controller (the last value of antiPiracyKey[] is off by 1)
*/
//LCD Start
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
//LCD End
//Used to enable the protection or not.
#define antiPiracy
#ifdef antiPiracy
//Configurable settings
const uint8_t serialLength = 8; //Set the length of Serial number you wish to match
uint8_t antiPiracyKey[] = {0xB3, 0x00, 0x0C, 0x94, 0xB3, 0x00, 0x94, 0xB3, 0x01}; //Change this with the output of Serial Monitor
//Static requirements for antiPiracy module
#define SIGRD 5
#include <avr/boot.h>
//This is your unique serial number
uint16_t serNumAddr[] = {0x000E, 0x000F, 0x0010, 0x0011, 0x0012, 0x0013, 0x0015, 0x0016, 0x0017}; //Z pointer addresses
uint8_t uniqueID[serialLength];
bool authentic = false;
#endif
//This is used to reset the device, creating an endless loop
void(* resetFunc) (void) = 0;
void setup() {
//LCD Start
lcd.begin(16, 2);
lcd.setCursor(0,0);
//LCD End
// Print a message to the LCD.
#ifdef antiPiracy
Serial.begin(9600);
delay(100);
copyRight();
if (authentic == false) {
lcd.print(F("Pirated!"));
delay(10*1000);
lcd.clear();
resetFunc();
}
else {
lcd.print(F("Authentic"));
delay(5*1000);
lcd.clear();
}
#endif
#ifndef antiPiracy
lcd.print(F("Hello World"));
Serial.println(F("Hello World"));
#endif
}
void loop() {
//YOUR CODE GOES HERE!!!
lcd.print(F("Code Continues"));
Serial.println(F("Code Continues"));
delay(60 *100);
lcd.clear();
}
#ifdef antiPiracy
void copyRight() {
for (int i = 0; i < serialLength; i++) {
uniqueID[i] = boot_signature_byte_get(serNumAddr[i]);
if( uniqueID[i] != antiPiracyKey[i] ) {
authentic = false;
Serial.println(F("Pirated Controller!"));
for (int i = 0; i < serialLength; i++) {
uniqueID[i] = boot_signature_byte_get(serNumAddr[i]);
Serial.print("0x");
if (uniqueID[i] < 16) {
Serial.write('0');
}
Serial.print(uniqueID[i], HEX);
if (i < serialLength - 1) {
Serial.print(", ");
}
else {
Serial.println();
}
}
break;
}
else {
authentic = true;
}
}
memset(uniqueID,0,sizeof(uniqueID));
if (authentic == true) {
Serial.println(F("Authentic Controller"));
}
}
#endif
