Naufal Faqiih Ashshiddiq
Published © GPL3+

Making a RFID Card Reader

Coding is so FUN! You can make RFID Reader to lock/unlock your SECRET ROOM!

BeginnerFull instructions provided1 hour75
Making a RFID Card Reader

Things used in this project

Hardware components

Female/Female Jumper Wires
Female/Female Jumper Wires
×7
RFID reader (generic)
×1
NodeMCU ESP8266 Breakout Board
NodeMCU ESP8266 Breakout Board
×1

Software apps and online services

Blynk
Blynk
Arduino IDE
Arduino IDE

Story

Read more

Code

RFID

C/C++
// Download MRFC522 in Arduino libraries

#include <SPI.h>
#include <MFRC522.h>

#define SS_PIN 4
#define RST_PIN 5

MFRC522 mfrc522(SS_PIN, RST_PIN);

void setup() {
  Serial.begin(9600);
  SPI.begin();
  mfrc522.PCD_Init();
  Serial.println("Put your card to the reader...");
}

void loop() {
  
  if( ! mfrc522.PICC_IsNewCardPresent()){
    return;
  }

  if( ! mfrc522.PICC_ReadCardSerial()){
    return;
  }

  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("Pesan : ");
  content.toUpperCase();

  if(content.substring(1) == "57 67 8B 7B"){
    Serial.println("Kartu cocok");
    Serial.println();
    delay(1000);
  }

  else if(content.substring(1) == "79 D0 24 A3"){
    Serial.println("Kartu cocok");
    Serial.println();
    delay(1000);
  }

  else{
    Serial.println("Kartu Tidak cocok");
    delay(1000);
  }

}

Credits

Naufal Faqiih Ashshiddiq

Naufal Faqiih Ashshiddiq

3 projects • 1 follower

Comments

Add projectSign up / Login