0% found this document useful (0 votes)
4 views3 pages

phabby arduino

The document contains an Arduino sketch for an RFID card reader system that identifies users based on their card UID. It initializes an LCD display to greet users and prompts them to insert their card, displaying their name upon successful identification. The code includes functions for checking the UID, sending the user's name to the serial monitor, and resetting the LCD display after a brief delay.

Uploaded by

kipchumbadenis22
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views3 pages

phabby arduino

The document contains an Arduino sketch for an RFID card reader system that identifies users based on their card UID. It initializes an LCD display to greet users and prompts them to insert their card, displaying their name upon successful identification. The code includes functions for checking the UID, sending the user's name to the serial monitor, and resetting the LCD display after a brief delay.

Uploaded by

kipchumbadenis22
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

#include <SPI.

h>

#include <MFRC522.h>

#include <Keypad.h>

#include <Wire.h>

#include <LiquidCrystal_I2C.h>

#define SS_PIN 53

#define RST_PIN 5

MFRC522 rfid(SS_PIN, RST_PIN);

LiquidCrystal_I2C lcd(0x27, 16, 2);

struct User {

String name;

byte uid[4];

};

User users[] = {

{ "Denis", {0xD1, 0xDF, 0xD5, 0x21} },

{ "Denis", {0xE1, 0x53, 0xDD, 0x0D} },

{ "JANE SMITH", {0x9B, 0xDD, 0x27, 0x1B} }

};

void setup() {

Serial.begin(9600);

SPI.begin();

rfid.PCD_Init();

lcd.init();

lcd.backlight();
lcd.setCursor(0, 0);

lcd.print("Welcome to MMUST");

lcd.setCursor(0, 1);

lcd.print("Insert Card");

void loop() {

if (!rfid.PICC_IsNewCardPresent() || !rfid.PICC_ReadCardSerial()) return;

for (User user : users) {

if (checkUID(rfid.uid.uidByte, user.uid)) {

sendUserName(user);

displayUserInfo(user);

delay(3000);

resetLCD();

break;

rfid.PICC_HaltA();

bool checkUID(byte *scannedUID, byte *knownUID) {

for (byte i = 0; i < 4; i++) {

if (scannedUID[i] != knownUID[i]) return false;

return true;

}
void sendUserName(User user) {

Serial.println(user.name);

void displayUserInfo(User user) {

lcd.clear();

lcd.setCursor(0, 0);

lcd.print("Hello, ");

lcd.print(user.name.substring(0, user.name.indexOf(" ")));

void resetLCD() {

lcd.clear();

lcd.setCursor(0, 0);

lcd.print("Welcome to MMUST");

lcd.setCursor(0, 1);

lcd.print("Insert Card");

You might also like