This circuit integrates an Arduino UNO microcontroller with an RFID-RC522 module and a 20x4 LCD display with an I2C interface. The Arduino UNO serves as the central processing unit, controlling the RFID reader for scanning RFID tags and displaying relevant information on the LCD screen. The RFID-RC522 module is used for reading RFID tags, and the LCD display provides a user interface to display messages such as prompts and the status of the RFID scans.
#include <SPI.h>
#include <MFRC522.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#define SS_PIN 10
#define RST_PIN 9
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance
// Set the LCD I2C address and dimensions
LiquidCrystal_I2C lcd(0x27, 20, 4);
void setup() {
Serial.begin(9600); // Initialize serial communications with the PC
SPI.begin(); // Init SPI bus
mfrc522.PCD_Init(); // Init MFRC522 card
lcd.init();
lcd.backlight();
lcd.setCursor(0, 0); // Set the cursor to the top-left position
lcd.print("SCAN ID TO LOGIN!");
//Serial.println("Scan a MIFARE Classic card");
}
void loop() {
// Look for new cards
if (!mfrc522.PICC_IsNewCardPresent() || !mfrc522.PICC_ReadCardSerial()) {
delay(50);
return;
}
// Show UID on serial monitor
Serial.print("Card UID:");
for (byte i = 0; i < mfrc522.uid.size; i++) {
Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
Serial.print(mfrc522.uid.uidByte[i], HEX);
}
Serial.println();
lcd.print("Welcome!");
// Halt PICC
mfrc522.PICC_HaltA();
// Stop encryption on PCD
mfrc522.PCD_StopCrypto1();
}
The LCD display is controlled through the Arduino UNO using the I2C protocol. The code for the LCD display is integrated into the Arduino UNO's sketch, as shown above.