Хэрэглэгдэхүүн:
- Ардиуно 1ш
- RFID RC 522 module 1ш
- RFID RC 522 key 1ш
- 10k потенциометр
- LCD дэлгэц 1ш
- Туршилтын хавтан 1ш
- Утас
Зарчмын схем
Зарчмын схем
Программ
//All Credit Technic 1510
//
//
//
//
#include <SPI.h>
#include <MFRC522.h>
#include <LiquidCrystal.h>
#define SS_PIN 10
#define RST_PIN 9
MFRC522 mfrc522(SS_PIN, RST_PIN);
LiquidCrystal lcd(6 , 7, 5, 4, 3, 2);
void setup()
{
SPI.begin();
mfrc522.PCD_Init();
lcd.begin(16, 2);
lcd.print("Scan RFID Card");
}
void loop()
{
if ( ! mfrc522.PICC_IsNewCardPresent())
{
return;
}
if ( ! mfrc522.PICC_ReadCardSerial())
{
return;
}
lcd.clear();
lcd.begin(16, 2);
lcd.print("UID tag :");
String content= "";
byte letter;
for (byte i = 0; i < mfrc522.uid.size; i++)
{
lcd.setCursor(0, 1);
lcd.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
lcd.print(mfrc522.uid.uidByte[i], HEX);
content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
content.concat(String(mfrc522.uid.uidByte[i], HEX));
}
lcd.clear();
lcd.begin(16, 2);
lcd.print("Message : ");
content.toUpperCase();
if (content.substring(1) == "E0 28 E9 87") //Plz change to your cards UID
{
lcd.setCursor(0,1);
lcd.print("Authorized");
delay(3000);
lcd.clear();
setup();
}
else {
lcd.setCursor(0, 1);
lcd.print(" Access denied");
delay(3000);
lcd.clear();
setup();
}
}