#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <MFRC522.h>
#define SS_PIN 5 // Pin for RFID SS
#define RST_PIN 22 // Pin for RFID RST
// Create instances for RFID and LCD
MFRC522 mfrc522(SS_PIN, RST_PIN);
LiquidCrystal_I2C lcd(0x27, 16, 2); // I2C address 0x27, LCD size 16x2
// Define RFID tag UIDs for shirts and jackets
String shirtTagUID = "1234567890";
String jacketTagUID = "0987654321";
void setup() {
// Initialize serial communication for debugging
Serial.begin(9600);
// Initialize RFID reader
SPI.begin();
mfrc522.PCD_Init();
Serial.println("Scan an RFID tag");
// Initialize LCD
lcd.begin(16, 2); // 16 columns, 2 rows
lcd.backlight(); // Turn on backlight
lcd.setCursor(0, 0);
lcd.print("Smart Wardrobe");
delay(2000); // Show "Smart Wardrobe" for 2 seconds
lcd.clear();
}
void loop() {
// Look for new RFID tags
if (mfrc522.PICC_IsNewCardPresent()) {
if (mfrc522.PICC_ReadCardSerial()) {
// Print UID of the detected tag to serial monitor
String tagUID = "";
for (byte i = 0; i < mfrc522.uid.size; i++) {
tagUID += String(mfrc522.uid.uidByte[i], HEX);
}
tagUID.toUpperCase();
Serial.print("Tag detected: ");
Serial.println(tagUID);
// Display the corresponding item on the LCD
lcd.clear();
lcd.setCursor(0, 0);
if (tagUID == shirtTagUID) {
lcd.print("Shirt Detected");
} else if (tagUID == jacketTagUID) {
lcd.print("Jacket Detected");
} else {
lcd.print("Unknown Tag");
}
delay(2000); // Display the message for 2 seconds
}
}
}