#include <SPI.h>
#include <MFRC522.h>
#include <Wire.h>
#include <U8g2lib.h>
#define RST_PIN 4
#define SS_PIN 5
#define BUTTON_PIN 2 // Define the pin for your button
// Initialize U8g2 library for SSD1306 OLED
U8G2_SSD1306_128X64_NONAME_F_SW_I2C u8g2(U8G2_R0, /* clock=*/ 22, /* data=*/ 21, /* reset=*/ U8X8_PIN_NONE);
MFRC522 mfrc522(SS_PIN, RST_PIN);
MFRC522::MIFARE_Key key;
bool cloningMode = false;
MFRC522::Uid targetUid;
// Your XBM image data (replace with your actual data)
static const unsigned char image_RFIDDolphinSuccess_bits[] = {0x00,0x00,0xc0,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x01,0x00,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0xc0,0x07,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x30,0x1c,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x88,0x3f,0x00,0x00,0x08,0xf8,0x07,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0xc4,0x73,0x00,0x00,0x08,0x07,0x08,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0xe4,0x61,0x00,0x00,0xc8,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0xe2,0xe1,0x00,0x00,0x38,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0xf2,0xf3,0x00,0x00,0x0c,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0xf2,0xff,0x00,0x00,0x03,0x00,0x20,0x00,0x00,0x20,0x00,0x00,0x20,0x80,0xf2,0xff,0x00,0xc0,0x00,0xc0,0x27,0x00,0x00,0x20,0x00,0x00,0x20,0x40,0xf3,0xff,0x00,0x30,0x00,0xb0,0x2a,0x00,0x00,0x20,0x00,0x00,0x20,0xa0,0xe6,0x7f,0x00,0x00,0x00,0x58,0x15,0x00,0x00,0x04,0x02,0x00,0x20,0x40,0xe5,0x7f,0x00,0x00,0x00,0xae,0x1a,0x00,0x00,0x24,0x02,0x00,0x10,0xa0,0xea,0x3f,0x00,0x00,0x00,0x55,0x0d,0x00,0x40,0x00,0x20,0x00,0x10,0x40,0x1d,0x1c,0x00,0x00,0xc0,0xaa,0x0a,0x00,0x80,0x00,0x10,0x00,0x10,0xa0,0x06,0x10,0x00,0x00,0x60,0x55,0x05,0x00,0x00,0x24,0x01,0x01,0x10,0x40,0x03,0x20,0x00,0x00,0xb8,0xaa,0x02,0x00,0x18,0x24,0x05,0x00,0x10,0x00,0x02,0x20,0x00,0x00,0x54,0x55,0x01,0x00,0x00,0xfc,0xc1,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0xab,0xaa,0x00,0x00,0x80,0x03,0x0e,0x00,0x10,0x00,0x00,0x00,0x00,0x80,0x55,0x55,0x00,0x00,0x04,0x1a,0x02,0x00,0x10,0x00,0x00,0x00,0x00,0xe0,0xaa,0x2a,0x00,0x00,0x10,0x1a,0x02,0x00,0x10,0xe0,0x00,0x00,0x00,0x58,0x55,0x1d,0x00,0x00,0x83,0x03,0x4e,0x0e,0x10,0x10,0x03,0x02,0x00,0xfe,0xaa,0x06,0x00,0x00,0x00,0x02,0x02,0x00,0x10,0x08,0x0c,0x04,0x80,0xff,0xd7,0x01,0x00,0x00,0x00,0x02,0x02,0x00,0x10,0x08,0x10,0x18,0xf8,0x07,0xfc,0x01,0x00,0x00,0x80,0x03,0xce,0x00,0x10,0x08,0x20,0xe0,0xff,0x00,0xf0,0x0f,0x00,0x00,0x30,0xfc,0x01,0x00,0x10,0x0c,0x40,0x00,0x7c,0x00,0xe0,0x3f,0x00,0x00,0x04,0x24,0x05,0x00,0x10,0x18,0x80,0x00,0xe0,0x00,0xc0,0xff,0x00,0x00,0x80,0x24,0x01,0x01,0x10,0x14,0x80,0x00,0x00,0x07,0x80,0xff,0x03,0x00,0x40,0x00,0x10,0x00,0x30,0x28,0x00,0x01,0x00,0x38,0x00,0xff,0x07,0x00,0x00,0x20,0x20,0x00,0x30,0x34,0x00,0x01,0x00,0xc0,0x03,0xfe,0x0f,0x00,0x00,0x04,0x02,0x00,0x38,0x68,0x00,0x02,0x00,0x00,0xfc,0xff,0x09,0x00,0x00,0x24,0x02,0x00,0x38,0x54,0x00,0x02,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x20,0x08,0x00,0x3c,0x6a,0x00,0x02,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x02,0x00,0x00,0x3c,0x54,0x00,0x04,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x70,0x00,0x00,0x3a,0x6a,0x00,0x04,0x00,0x00,0x00,0xc0,0x00,0x00,0x00,0x88,0x00,0x00,0x3e,0x55,0x00,0x04,0x00,0x15,0x00,0x38,0x00,0x00,0x00,0x86,0x00,0x00,0xbb,0x6a,0x00,0x08,0x00,0xea,0xff,0x07,0x00,0x00,0x80,0x81,0x00,0x00,0x7d,0x55,0x00,0x08,0x00,0x54,0x55,0x00,0x00,0x00,0x70,0x80,0x00,0x00,0xba,0x6a,0x00,0x08,0x00,0xa8,0xea,0x03,0x00,0x00,0x0f,0x80,0x00,0x00,0x7d,0x55,0x00,0x10,0x00,0x40,0xd5,0x3c,0x00,0xf0,0x00,0x40,0x00,0x00,0xfa,0x2a,0x00,0x10,0x00,0x80,0xaa,0xc0,0xff,0x0f,0x00,0x40,0x00,0x00,0x7d,0x35,0x00,0x10,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0xfa,0x2a,0x00,0x20,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x10,0x00,0x00,0x75,0x35,0x00,0x20,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x08,0x00,0x00};
static const unsigned char image_DolphinDone_bits[] = {0x00,0x00,0x00,0xf8,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x00,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x20,0x00,0x3e,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x20,0x80,0xc1,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x01,0x00,0xd0,0x0f,0x00,0x00,0x00,0x10,0x20,0x3f,0x02,0x00,0x30,0x30,0x00,0x00,0x00,0x08,0xa0,0x4f,0x02,0x00,0x0c,0x40,0x00,0x00,0x00,0x08,0xd0,0x87,0x04,0x00,0x03,0x40,0x00,0x00,0x00,0x08,0xd0,0x87,0x04,0xc0,0x00,0x80,0x00,0x00,0x00,0x08,0xd0,0xcf,0x04,0x30,0x00,0x80,0x00,0x00,0x00,0x08,0xd0,0xff,0x04,0x0c,0x00,0x9f,0x00,0x00,0x00,0x08,0xd0,0xff,0x05,0x03,0xc0,0xa0,0x00,0x00,0x00,0x04,0xe0,0x1f,0x06,0x00,0x30,0xc0,0x00,0x00,0x00,0x04,0xa0,0x07,0x08,0x00,0x08,0x40,0x00,0x00,0x00,0x04,0x40,0x03,0x00,0x00,0x06,0x40,0x00,0x00,0x00,0x04,0x80,0x01,0x00,0x00,0x01,0x20,0x70,0x00,0x00,0x04,0x00,0x01,0x00,0xc0,0x00,0x20,0x88,0x00,0x00,0x04,0x00,0x80,0x00,0x20,0x00,0x10,0x88,0x00,0x00,0x04,0x00,0x80,0x00,0x18,0x00,0x08,0x08,0x01,0x00,0x04,0x00,0x00,0x01,0x04,0x00,0x04,0x08,0x01,0x00,0x04,0x00,0x00,0x02,0x03,0x00,0x03,0x08,0x1f,0x00,0x04,0x00,0x00,0xfc,0x00,0x80,0x01,0x88,0x20,0x00,0x04,0x00,0x00,0x00,0x00,0xc0,0x00,0x48,0x40,0x00,0x04,0x00,0x00,0x00,0x00,0xf0,0x00,0x48,0x40,0x00,0x08,0x00,0x00,0x00,0x00,0xf8,0x00,0x48,0x80,0x00,0x08,0x00,0x00,0x00,0x00,0xfe,0x01,0x48,0x80,0x00,0x08,0x00,0x00,0x38,0xc0,0xbf,0x02,0x44,0x80,0x00,0x0c,0x00,0x00,0x44,0xfc,0xbf,0x0c,0x82,0x80,0x00,0x0e,0x00,0x00,0x44,0xf0,0x9f,0x30,0x81,0x80,0x00,0x0b,0x00,0x00,0x84,0x80,0x8f,0xc0,0x00,0x41,0x80,0x0d,0x00,0x00,0x84,0x00,0x80,0x40,0x00,0x62,0xc0,0x0a,0x00,0x00,0x84,0x0f,0x80,0x00,0x00,0x3c,0x40,0x05,0x00,0x00,0x44,0x10,0x00,0x01,0x00,0x10,0xa0,0x06,0x00,0x00,0x02,0x20,0x00,0x01,0x00,0x10,0x60,0x07,0x00,0x00,0x02,0x20,0x00,0x01,0x00,0x08,0xb0,0x02,0x00,0x80,0x01,0x40,0x00,0x01,0x00,0x08,0x50,0x03,0x00,0x60,0x00,0x40,0x00,0x45,0x00,0x04,0xa8,0x01,0x00,0x18,0x00,0x40,0x00,0x01,0x00,0x02,0x58,0x01,0x00,0x07,0x00,0x40,0x00,0x55,0x51,0x01,0xac,0x00,0xe0,0x00,0x00,0x40,0x00,0x01,0x80,0x00,0xd4,0x00,0x18,0x00,0x00,0x20,0x00,0x55,0x55,0x00,0xaa,0x00,0x04,0x00,0x00,0x10,0x00,0x0b,0x2a,0x00,0xd6,0x00,0x00,0x00,0x00,0x0c,0x00,0x55,0x15,0x00,0x6b,0x00,0x00,0x00,0x00,0x03,0x80,0xaa,0x0e,0x00,0x55,0x00,0x00,0x00,0x80,0x01,0x80,0x55,0x03,0x00,0x6b,0x00,0x00,0x00,0xc0,0x01,0x80,0xff,0x00,0x00,0x55,0x00,0x00,0x00,0xf0,0x01,0x80,0x00,0x00,0x00,0x6b,0x00,0x00,0x00,0xfc,0x00,0x80,0x00,0x00,0x00};
static const uint8_t image_arrow_curved_right_up_down_bits[] = {0x11,0x36,0x7c,0x30,0x10};;
static const uint8_t image_Layer_4_bits[] = {0xff,0xff,0xff,0xff,0xff,0x01,0x01,0x00,0x00,0x00,0x00,0x03,0x01,0x00,0x00,0x00,0x00,0x05,0x01,0x00,0x00,0x00,0x00,0x05,0xf1,0x07,0x00,0x00,0x00,0x05,0x11,0x04,0x00,0x00,0x00,0x05,0x11,0x04,0x00,0x00,0x00,0x05,0x11,0x04,0x00,0x00,0x00,0x05,0x11,0x04,0x00,0x00,0x00,0x05,0x11,0x04,0x00,0x00,0x00,0x05,0x11,0x04,0x00,0x00,0x00,0x05,0x11,0x04,0x00,0x00,0x00,0x05,0x11,0x04,0x00,0x00,0x00,0x05,0x11,0x04,0x00,0x00,0x00,0x05,0x11,0x04,0x00,0x00,0x00,0x05,0xf1,0x07,0x00,0x00,0x00,0x05,0x01,0x00,0x00,0x00,0x00,0x05,0x01,0x00,0x00,0x00,0x00,0x05,0x01,0x00,0x00,0x00,0x00,0x05,0xff,0xff,0xff,0xff,0xff,0x05,0x03,0x00,0x00,0x00,0x00,0x06,0x06,0x00,0x00,0x00,0x00,0x04,0xfc,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0xf0,0x01,0x00,0x00,0x00,0x00,0xf0,0x01,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0x03,0x01,0x00,0xf0,0x01,0x00,0x04,0x01,0x00,0xf0,0x01,0x00,0x04,0x01,0x00,0xf0,0x01,0x00,0x04,0x01,0x00,0xf0,0x01,0x00,0x04,0x01,0x00,0xf0,0x01,0x00,0x04,0x01,0x00,0xfe,0x0f,0x7e,0x04,0x01,0x00,0xfc,0x07,0x99,0x04,0x01,0x00,0xf8,0x03,0xa5,0x04,0x01,0x00,0xf0,0x01,0xa5,0x04,0x01,0x00,0xe0,0x00,0x99,0x04,0x01,0x00,0x40,0x00,0x7e,0x04,0x01,0x00,0x00,0x00,0x00,0x04,0x01,0x00,0x00,0x00,0x00,0x04,0x01,0x00,0x00,0x00,0x00,0x04,0xf9,0x3f,0xff,0x3f,0x00,0x04,0x01,0x00,0x00,0x00,0x00,0x04,0xf9,0x7c,0x00,0x00,0x00,0x04,0x01,0x00,0x00,0x00,0x00,0x04,0x01,0x00,0x00,0x00,0x00,0x04,0xff,0xff,0xff,0xff,0xff,0x07,0xfe,0xff,0xff,0xff,0xff,0x03};
static const uint8_t image_RFIDDolphinSend_bits[] = {0x00,0x00,0xfe,0x1f,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x01,0xe0,0x01,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x06,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0x00,0x00,0x18,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x20,0x00,0x00,0x01,0x01,0x00,0xa0,0x0a,0x00,0x00,0x01,0x00,0x00,0x40,0x00,0x00,0x02,0x02,0x00,0xa0,0x0a,0x00,0x80,0x00,0x00,0x00,0x80,0x00,0x00,0x02,0x02,0x00,0xf0,0x1f,0x00,0x40,0x00,0x00,0x00,0x00,0x01,0x00,0x04,0x02,0x00,0x08,0x20,0x00,0x20,0x00,0x00,0x00,0x00,0x02,0x00,0x04,0x04,0x00,0xe4,0x4d,0x00,0x20,0x00,0x00,0x00,0x3c,0x04,0x10,0x08,0x04,0x00,0x17,0xcc,0x01,0x10,0x00,0x00,0x00,0x42,0x04,0x20,0x08,0x04,0x00,0x14,0x40,0x00,0x10,0x00,0x00,0x00,0x81,0x08,0x20,0x08,0x04,0x00,0x07,0xd0,0x01,0x08,0x06,0x00,0x80,0x18,0x09,0x20,0x08,0x04,0x00,0x14,0x50,0x00,0x08,0x09,0x08,0x80,0x24,0x09,0x20,0x08,0x04,0x00,0x07,0xd0,0x01,0x84,0x10,0x08,0x80,0x24,0x11,0x20,0x08,0x04,0x00,0x14,0x50,0x00,0xc4,0x10,0x10,0x80,0x24,0x11,0x10,0x08,0x04,0x00,0x17,0xd0,0x01,0x44,0x10,0x10,0x80,0x24,0x11,0x00,0x04,0x04,0x00,0xa4,0x4f,0x00,0x46,0x20,0x20,0x80,0x24,0x11,0x00,0x04,0x02,0x00,0x08,0x20,0x00,0x2a,0x20,0x20,0x80,0x24,0x11,0x00,0x02,0x02,0x00,0xf0,0x1f,0x00,0x36,0x20,0x40,0x80,0x18,0x11,0x00,0x02,0x02,0x00,0xa0,0x0a,0x00,0x1b,0xe0,0x80,0x00,0x81,0x10,0x00,0x01,0x01,0x00,0xa0,0x0a,0x00,0x0d,0xe0,0x00,0x01,0x42,0x10,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x07,0xe0,0x01,0x00,0x3c,0x18,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x03,0xf0,0x01,0x00,0x00,0x14,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x01,0xf0,0x03,0x00,0x00,0x0a,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0xd0,0xff,0x01,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xd0,0xff,0x01,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0xff,0x00,0x00,0x0e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x3c,0x00,0x1f,0x0e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x60,0x80,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0x00,0x08,0x00,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x00,0x02,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x05,0x18,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x02,0x20,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x05,0xc0,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xa0,0x02,0x00,0x01,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x50,0x01,0x00,0x06,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0x00,0x14,0x08,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x58,0x00,0x6a,0x30,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xac,0x00,0xd4,0x41,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x54,0x00,0xa8,0x83,0x01,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x2a,0x00,0x50,0x0f,0x02,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x15,0x00,0xa0,0x1e,0xfc,0x5f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0b,0x00,0x40,0x7d,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0xa0,0xfa,0x01,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf5,0x07,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xea,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xd0,0x5f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xa0,0x9e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x95,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x9a,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
static const uint8_t image_DolphinMafia_bits[] = {0x00,0x00,0x00,0x00,0x80,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x01,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x2f,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0x15,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xaf,0x0a,0x00,0x40,0x00,0xfe,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x55,0x15,0x00,0x80,0xf0,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xaa,0x0a,0x00,0x80,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x55,0x15,0x00,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xaa,0x2a,0xe0,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x55,0x55,0xfc,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xaa,0xaa,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x55,0xd5,0xff,0x7f,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xaa,0xfa,0xff,0x2b,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x55,0xfd,0x7f,0x05,0xe8,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xab,0xfe,0xaf,0x00,0xf1,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x55,0xff,0x15,0xe0,0x37,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xeb,0xff,0x0a,0xfc,0x7f,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf6,0x7f,0x81,0xff,0xef,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0xfa,0xaf,0xe0,0x3f,0xee,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0xfe,0x57,0xf8,0x0f,0xce,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0xff,0x2b,0xfc,0x1f,0x07,0x00,0x30,0x00,0x00,0x00,0x00,0x80,0x02,0x00,0xc0,0xff,0x15,0xfc,0xff,0x07,0x00,0xc0,0x00,0x00,0x00,0x00,0x20,0x02,0x00,0xe0,0xbf,0x0a,0xfc,0xff,0x03,0x00,0x00,0x01,0x00,0x00,0x00,0x18,0x01,0x00,0xf8,0x5f,0x05,0xf8,0xff,0x03,0x00,0x00,0x02,0x00,0x00,0x60,0x86,0x00,0x00,0xfc,0xaf,0x02,0xfa,0xff,0x01,0x00,0x00,0x02,0x00,0x30,0x1d,0x40,0x00,0x00,0xff,0x57,0x01,0xf5,0x7f,0x00,0x00,0xc0,0x02,0x00,0x08,0x00,0x30,0x00,0x80,0xff,0xab,0x80,0xea,0x1f,0x00,0x00,0xe0,0xfb,0x03,0x04,0x00,0x0e,0x00,0xc0,0xff,0x57,0x00,0xf5,0x03,0x00,0x00,0xf8,0x02,0x00,0x04,0x60,0x01,0x00,0xe0,0xff,0x2b,0x80,0x0a,0x04,0x00,0x00,0xc6,0xc2,0x0f,0x04,0x03,0x00,0x00,0xf0,0xff,0x16,0x00,0x05,0x08,0x00,0x80,0x01,0x02,0x00,0xf0,0x00,0x00,0x00,0xf0,0x3f,0x0a,0x80,0x02,0x00,0x00,0x60,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0xe0,0x03,0x06,0x00,0x03,0x00,0x00,0x1c,0x00,0x01,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x0a,0x00,0x82,0x00,0x00,0x03,0x80,0x00,0x00,0x24,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x82,0x00,0xe0,0x00,0x40,0x00,0x00,0x22,0x00,0x00,0x00,0x00,0x00,0x0a,0x00,0x00,0x03,0x1e,0x00,0x30,0x00,0x00,0x22,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0xfc,0x01,0x00,0x0e,0x00,0x00,0x22,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0xc0,0x01,0x00,0x00,0x21,0x00,0x00,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x00,0xe1,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x07,0x00,0x00,0xf8,0x10,0x03,0x00,0x00,0x00,0x80,0x01,0x00,0x00,0x00,0xf0,0x04,0x00,0x00,0x04,0x10,0x04,0x00,0x00,0x00,0xe0,0x03,0x00,0x00,0x00,0x0f,0x04,0x00,0x00,0x04,0x10,0x08,0x00,0x00,0x00,0xb0,0x01,0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x04,0x10,0x08,0x00,0x00,0x00,0xd8,0xff,0xff,0xff,0x3f,0x00,0x28,0x00,0x00,0x08,0x10,0x08,0x00,0x00,0x00,0xec,0x01,0x00,0x00,0xe0,0x1f,0x28,0x00,0x00,0x10,0x10,0x08,0x00,0x00,0x00,0xd6,0x02,0x00,0x00,0x00,0x30,0x50,0x00,0x00,0x10,0x10,0x04,0x00,0x00,0x00,0xeb,0x05,0x00,0x00,0x00,0x50,0x50,0x00,0x00,0x10,0x20,0x02,0x00,0x00,0x80,0xd4,0x0a,0x00,0x00,0x00,0x90,0x50,0x00,0x00,0x08,0xc0,0x01,0x00,0x00,0x40,0xea,0x15,0x00,0x00,0x00,0x08,0x61,0x00,0x00,0x0c,0x00,0x01,0x00,0x00,0x20,0xf4,0xff,0xff,0x01,0x00,0x08,0x62,0x00,0x00,0x12,0x80,0x00,0x00,0x00,0x10,0xea,0x15,0x00,0xfe,0x00,0x08,0xe4,0x01,0x00,0x21,0x80,0x00,0x00,0x00,0x10,0xf4,0x0a,0x00,0x00,0x0f,0x04,0xa8,0x06,0xc0,0xc0,0x40,0x00,0x00,0x00,0x08,0xe8,0x05,0x00,0x00,0x30,0x04,0x50,0x19,0x38,0x01,0x47,0x00,0x00,0x00,0x04,0xf4,0x02,0x00,0x00,0xc0,0x04,0xc0,0xe2,0x07,0x06,0x38,0x00,0x00,0x00,0x04,0xf8,0x05,0x00,0x00,0x00,0x03,0x40,0x01,0x00,0x18,0x20,0x00,0x00,0x00,0x02,0xf0,0x02,0x00,0x00,0x00,0x00,0x80,0x02,0x00,0x60,0x10,0x00,0x00,0x00,0x02,0xf8,0x01,0x00,0x00,0x00,0x00,0x80,0x05,0x00,0x80,0x11,0x00,0x00,0x00,0x01,0xf0,0x02,0x00,0x00,0x00,0x00,0x80,0x0a,0x00,0x00,0x0e,0x00,0x00,0x00};
static const uint8_t image_DolphinWait_bits[] = {0x00,0x00,0x00,0xfc,0x0f,0x00,0x00,0x00,0x00,0x00,0x80,0x03,0x70,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x80,0x01,0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x06,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x20,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x04,0xc0,0x03,0x00,0x00,0x06,0x00,0x00,0x04,0xb0,0x0f,0x00,0x00,0x07,0x00,0x00,0x02,0xc8,0x19,0x00,0x80,0x0c,0x00,0x00,0x02,0xe4,0x30,0x00,0x80,0x0c,0x00,0x00,0x02,0xe4,0x30,0x00,0x80,0x0e,0x00,0x00,0x01,0xf2,0x79,0x00,0xc0,0x3f,0x00,0x00,0x01,0xf2,0x7f,0x00,0x30,0x40,0x00,0x00,0x01,0xf2,0x7f,0x00,0x0c,0x80,0x00,0x00,0x01,0xe2,0x5f,0x00,0x03,0x00,0x01,0x00,0x01,0xe2,0x5f,0xc0,0x00,0x00,0x01,0x00,0x01,0x84,0x2f,0x30,0x00,0x00,0x01,0x00,0x01,0x04,0x20,0x0c,0x00,0x3c,0x01,0x80,0x00,0xe8,0x17,0x00,0x00,0x43,0x01,0x80,0x00,0x18,0x08,0x00,0xc0,0x80,0x01,0x80,0x00,0x08,0x10,0x00,0x30,0x80,0x00,0x80,0x00,0x04,0x00,0x00,0x0c,0x80,0x00,0xc0,0x00,0x04,0x00,0x00,0x03,0x80,0x00,0xe0,0x00,0x00,0x00,0xc0,0x00,0x40,0x00,0xb0,0x00,0x80,0x00,0x30,0x00,0x20,0x00,0xd0,0x00,0x80,0x00,0x0c,0x00,0x20,0x00,0xa8,0x00,0x00,0x01,0x03,0x00,0x10,0x00,0xd4,0x00,0x00,0xfe,0x00,0x00,0x08,0x00,0xac,0x03,0x00,0x00,0x00,0x00,0x0c,0x00,0xd6,0x10,0x00,0x00,0x00,0x00,0x0e,0x00,0x2a,0x00,0x00,0x00,0xfc,0xc0,0x07,0x00,0x15,0x80,0x00,0x00,0x03,0xff,0x07,0x00,0x0b,0x00,0x00,0x80,0x00,0x02,0x0e,0x00,0x0d,0x00,0x02,0x60,0x78,0x02,0x1c,0x00,0x06,0x00,0x0c,0x58,0x08,0x02,0x60,0x00,0x05,0x00,0xf8,0x47,0x08,0x07,0x80,0x00,0x02,0x00,0xf0,0xc1,0xc0,0x0d,0x00,0x01,0x03,0x00,0xbc,0x80,0xff,0x1a,0x00,0x02,0x01,0x80,0x43,0x00,0x7f,0x15,0x00,0x06,0x01,0x40,0x20,0x00,0xb0,0x2a,0x00,0x06,0x01,0x00,0x20,0x00,0x60,0x35,0x00,0x06,0x00,0x00,0x10,0x00,0xc0,0xfa,0x03,0x06,0x00,0x00,0x10,0x00,0xe0,0x1f,0x1c,0x06,0x00,0x00,0x10,0x00,0xff,0x03,0x60,0x07,0x00,0x00,0x20,0xfc,0x3f,0x00,0x80,0x07,0x00,0x00,0xc0,0xff,0x03,0x00,0x00,0x03,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0x01};
static const unsigned char image_dolph_cry_bits[] = {0x00,0x00,0xf0,0x7f,0x00,0x00,0x00,0x00,0x00,0x0e,0x80,0x03,0x00,0x00,0x00,0x80,0x01,0x00,0x0c,0x00,0x00,0x00,0x60,0x00,0x00,0x30,0x00,0x00,0x00,0x10,0x00,0x00,0x40,0x00,0x00,0x00,0x08,0x00,0x00,0x80,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x01,0x00,0x00,0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x01,0x00,0x00,0x00,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x08,0x00,0x80,0x00,0x00,0x00,0x00,0x08,0x00,0x40,0x00,0x00,0x00,0x00,0x10,0x00,0x40,0x00,0x00,0x00,0x00,0x10,0x00,0x20,0x00,0x00,0x00,0x00,0x20,0x00,0x20,0x00,0x00,0x00,0x00,0x20,0x00,0x10,0x00,0x00,0x00,0x00,0x20,0x00,0x10,0x00,0x00,0x00,0x00,0x40,0x00,0x10,0x00,0x00,0x20,0x00,0x40,0x00,0x08,0x00,0x00,0x1e,0x00,0x44,0x00,0x08,0x00,0x00,0x00,0x00,0x58,0x00,0x08,0x00,0x00,0x00,0x00,0x40,0x00,0x08,0x00,0x07,0x00,0x00,0x40,0x00,0x04,0x00,0x1f,0x00,0x00,0x40,0x00,0x04,0x00,0xff,0x07,0x00,0x66,0x00,0x04,0x80,0xff,0x07,0x00,0x7e,0x00,0x04,0x40,0xfd,0x07,0x00,0x7e,0x00,0x04,0x20,0xf9,0x01,0x70,0x7c,0x00,0x04,0x90,0x00,0x00,0x81,0x38,0x00,0x04,0x90,0x00,0x40,0x00,0x21,0x00,0x02,0x90,0x00,0x00,0x00,0x22,0x00,0x02,0x60,0x00,0x00,0x00,0x24,0x00,0x02,0x00,0x00,0x00,0x00,0x28,0x00,0x02,0x00,0x00,0x00,0x00,0x30,0x00,0x02,0x00,0x00,0x1e,0x00,0x60,0x00,0x02,0x00,0x00,0xe1,0x00,0xc0,0x00,0x02,0x00,0x08,0x00,0x03,0x80,0x00,0x01,0x00,0x08,0x00,0x0c,0x00,0x01,0x01,0x00,0x10,0x00,0x10,0x00,0x01,0x01,0x00,0x00,0x00,0x60,0x00,0x01,0x01,0x00,0x00,0x18,0x80,0x01,0x01,0x01,0x00,0x00,0x78,0x00,0xfe,0x00,0x01,0x00,0x00,0xf0,0x01,0x80,0x00,0x00,0x00,0x00,0xe0,0x0f,0x40,0x00,0x00,0x00,0x00,0xc0,0x7f,0x20,0x00,0x00,0x00,0x00,0x80,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0xfe,0x07,0x00,0x00,0x00,0x00,0x00,0xf8,0x07,0x00,0x00,0x00,0x00,0x00,0xc0,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00};
void showSplashScreen() {
u8g2.clearBuffer();
u8g2.setBitmapMode(1);
u8g2.setFontMode(1);
u8g2.drawXBM(6, 1, 115, 62, image_DolphinMafia_bits);
u8g2.sendBuffer();
delay(5000); // Display for 5 seconds
}
void showWaitScreen() {
u8g2.clearBuffer();
u8g2.setBitmapMode(1);
u8g2.setFontMode(1);
u8g2.drawXBM(0, 10, 59, 54, image_DolphinWait_bits);
u8g2.setFont(u8g2_font_4x6_tr);
u8g2.drawStr(70, 35, "Press to read");
u8g2.sendBuffer();
}
void showSuccessScreen() {
u8g2.clearBuffer();
u8g2.setFontMode(1);
u8g2.setBitmapMode(1);
u8g2.drawXBM(0, 7, 108, 57, image_RFIDDolphinSuccess_bits);
u8g2.sendBuffer();
delay(2000); // Display for 2 seconds
}
void showDoneScreen() {
u8g2.clearBuffer();
u8g2.setFontMode(1);
u8g2.setBitmapMode(1);
u8g2.drawXBM(0, 6, 80, 58, image_DolphinDone_bits);
u8g2.setFont(u8g2_font_4x6_tr);
u8g2.drawStr(70, 24, "Want to clone?");
u8g2.sendBuffer();
}
void showReadingStartScreen() {
u8g2.clearBuffer();
u8g2.setBitmapMode(1);
u8g2.setFontMode(1);
u8g2.setFont(u8g2_font_4x6_tr);
u8g2.drawStr(14, 7, "Place the card or the tag");
u8g2.drawStr(12, 14, "on the back and hold still");
u8g2.drawXBM(42, 16, 43, 47, image_Layer_4_bits);
u8g2.drawStr(102, 56, "start");
u8g2.drawXBM(113, 58, 7, 5, image_arrow_curved_right_up_down_bits);
u8g2.sendBuffer();
delay(5000); // Display for 5 seconds
}
void showCloningScreen() {
u8g2.clearBuffer();
u8g2.setBitmapMode(1);
u8g2.setFontMode(1);
u8g2.drawXBM(0, 3, 97, 61, image_RFIDDolphinSend_bits);
u8g2.sendBuffer();
}
void showTryAgainScreen() {
u8g2.clearBuffer();
u8g2.setFontMode(1);
u8g2.setBitmapMode(1);
u8g2.drawXBM(0, 10, 49, 54, image_dolph_cry_bits);
u8g2.setFont(u8g2_font_4x6_tr);
u8g2.drawStr(70, 35, "Try again");
u8g2.sendBuffer();
}
void waitForButtonPress() {
while (digitalRead(BUTTON_PIN) == HIGH) { // Wait for button press (LOW when pressed)
delay(50); // Debounce delay
}
// Wait for button release
while (digitalRead(BUTTON_PIN) == LOW) {
delay(50);
}
}
void startReadingProcess() {
showReadingStartScreen();
showCloningScreen();
}
void setup() {
Serial.begin(115200);
SPI.begin();
mfrc522.PCD_Init();
pinMode(BUTTON_PIN, INPUT_PULLUP);
u8g2.begin();
u8g2.setFont(u8g2_font_6x10_tf);
u8g2.setFontRefHeightExtendedText();
u8g2.setDrawColor(1);
u8g2.setFontPosTop();
u8g2.setFontDirection(0);
showSplashScreen();
showWaitScreen();
waitForButtonPress();
startReadingProcess();
for (byte i = 0; i < 6; i++) {
key.keyByte[i] = 0xFF;
}
}
void loop() {
// Reset the loop if no new card present on the sensor/reader
if (!mfrc522.PICC_IsNewCardPresent()) {
if (cloningMode) {
showCloningScreen();
}
delay(200);
return;
}
// Try to read the card
if (!mfrc522.PICC_ReadCardSerial()) {
// Reading failed - show try again screen
showTryAgainScreen();
waitForButtonPress();
startReadingProcess();
return;
}
// Card successfully read
if (cloningMode) {
// Attempt to clone the UID to the target tag
if (writeUidToTag(mfrc522, targetUid)) {
showSuccessScreen(); // Show the new success screen
showWaitScreen(); // Return to waiting state
} else {
showTryAgainScreen();
waitForButtonPress();
}
cloningMode = false;
showWaitScreen();
waitForButtonPress();
startReadingProcess();
} else {
// Normal read mode
showSuccessScreen(); // Show the new success screen
showDoneScreen(); // Ask if user wants to clone
waitForButtonPress();
// Store the UID for cloning and enter cloning mode
targetUid = mfrc522.uid;
cloningMode = true;
showCloningScreen();
}
mfrc522.PICC_HaltA();
mfrc522.PCD_StopCrypto1();
}
void printUid(MFRC522::Uid uid, uint8_t yPos) {
char uidStr[30];
sprintf(uidStr, "%02X %02X %02X %02X",
uid.uidByte[0], uid.uidByte[1],
uid.uidByte[2], uid.uidByte[3]);
u8g2.drawStr(0, yPos, uidStr);
}
bool writeUidToTag(MFRC522 &mfrc522, MFRC522::Uid uid) {
MFRC522::PICC_Type piccType = mfrc522.PICC_GetType(mfrc522.uid.sak);
if (piccType != MFRC522::PICC_TYPE_MIFARE_1K &&
piccType != MFRC522::PICC_TYPE_MIFARE_4K &&
piccType != MFRC522::PICC_TYPE_MIFARE_UL) {
return false;
}
return mfrc522.MIFARE_SetUid((byte *)uid.uidByte, uid.size, true);
}