I'm still learning the ropes so forgive me if the answer to this is obvious. I'm using the Arduino Uno and a RC522 RFID card reader. My aim is to scan a card on the reader and have the I2C OLED display show me the name of the person who has scanned their card. This is the code for the program I'm using -
#include <U8glib.h>
#include <LiquidCrystal.h>
#include <RFID.h>
#include <SPI.h>
#define SS_PIN 10
#define RST_PIN 9
RFID rfid(SS_PIN, RST_PIN);
int serNum[5];
String cardno;
int interval = 15000; // millisec
long now = 0;
long lasttime = millis();
// change Reader ID to your name
String readerID = "CCE3050";
void setup() {
Serial.begin(9600);
SPI.begin();
rfid.init();
}
void loop() {
now = millis();
if (now > lasttime + interval) {
lasttime = now;
Serial.print(readerID);
Serial.print(":");
Serial.println("I am alive");
}
if (rfid.isCard()) {
if (rfid.readCardSerial()) {
lasttime = now;
cardno = String(rfid.serNum[0]) +
String(rfid.serNum[1]) +
String(rfid.serNum[2]) +
String(rfid.serNum[3]) +
String(rfid.serNum[4]);
Serial.print(readerID);
Serial.print(":");
Serial.println(cardno);
}
}
delay(5000);
}
So far, each time a card is tagged, the card number is displayed on the serial monitor. However, I would like to assign a name to the card and display that name on the OLED whenever the card is tagged onto the reader. Is there a way to do this?