#include <LiquidCrystal_I2C.h>
#include <SPI.h>
#include <MFRC522.h>
#include <Wire.h>
#include <EEPROM.h>
#define SS_PIN 53 //Arduino Uno
#define RST_PIN 5
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.
LiquidCrystal_I2C lcd(0x3F, 16, 2);
void setup() {
Serial.begin(9600); // Initialize serial communications with the PC
SPI.begin(); // Init SPI bus
mfrc522.PCD_Init(); // Init MFRC522 card
lcd.begin();
}
void loop()
{
lcd.clear();
lcd.print("Scan Your Card");
// Look for new cards
if ( ! mfrc522.PICC_IsNewCardPresent())
{
return;
}
// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial())
{
return;
}
//Show UID on serial monitor
Serial.print("UID tag :");
String content= "";
byte letter;
for (byte i = 0; i < mfrc522.uid.size; i++)
{
Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
Serial.print(mfrc522.uid.uidByte[i], HEX);
content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
content.concat(String(mfrc522.uid.uidByte[i], HEX));
}
Serial.println();
Serial.print("Message : ");
content.toUpperCase();
String const teac = "95 A5 16 CB";
String const stu = "25 C0 62 76";
int addrTeac = 0;
if (content.substring(1) == teac) //change here the UID of the card/cards that you want to give access
{
Serial.println("Authorized Access");
for (byte i = 0; i < mfrc522.uid.size; i++)
{
EEPROM.write(addrTeac,teac);
teac = EEPROM.read(addrTeac);
Serial.print(addrTeac);
Serial.print("\t");
Serial.print(teac);
Serial.println();
}
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Authorized Access");
lcd.setCursor(0,1);
lcd.print("Welcome Teacher");
delay (1000);
lcd.clear();
lcd.setCursor(0,1);
lcd.print("AutoLock after ");
for(int j=5; j>0; j--){
lcd.setCursor (15,1);
lcd.print(j);
delay (1000);
}
}
else {
Serial.println("Access Denied");
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Access Denied");
lcd.setCursor(0,1);
lcd.print("Card Not Regist");
delay (2000);
}
}
I have 1 RFID card as a teacher and the other students. I scan the card when a teacher, I want the data in the RFID ID into the eeprom. how RFID data conversion in order to enter into eeprom?
especially in this line
if (content.substring(1) == teac) //change here the UID of the card/cards that you want to give access
{
Serial.println("Authorized Access");
for (byte i = 0; i < mfrc522.uid.size; i++)
{
EEPROM.write(addrTeac,teac);
teac = EEPROM.read(addrTeac);
Serial.print(addrTeac);
Serial.print("\t");
Serial.print(teac);
Serial.println();
}
need help please master. thanks