abiodun1991
Published © LGPL

The Application of RFID card and Arduino with I2c Lcd

The Application of RFID card and Arduino with I2c Lcd display the ID number with LCD display unit

AdvancedFull instructions provided1,312
The Application of RFID card and Arduino with I2c Lcd

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
RFID reader (generic)
×1
Female/Female Jumper Wires
Female/Female Jumper Wires
×1
Alphanumeric LCD, 16 x 2
Alphanumeric LCD, 16 x 2
×1

Software apps and online services

Arduino IDE
Arduino IDE

Schematics

circuit

Code

the code

Arduino
#include <SPI.h>  
#include <MFRC522.h> 
#include <Wire.h> 
#include <LiquidCrystal_I2C.h>
#include <Servo.h>
LiquidCrystal_I2C lcd(0x27,16,2);
#define SS_PIN 10
#define RST_PIN 9
MFRC522 mfrc522(SS_PIN, RST_PIN);   
Servo myServo;

int *aux;
int card1[4];
int flag = 0;
int led = 13;
int cnt =0;

void setup() {
        pinMode(led, OUTPUT);
        
        lcd.init();
        lcd.backlight();
    SPI.begin();        
    mfrc522.PCD_Init();   
        lcd.print(" Apropie cardul");
        lcd.setCursor(0,1);
        lcd.print(" Pentru acces  ");

        myServo.attach(3); 
        myServo.write(0);
}

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

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

   
    
    for (byte i = 0; i < mfrc522.uid.size; i++) {
            aux[i]= mfrc522.uid.uidByte[i];
    } 
           if(flag == 0)
           {
             lcd.clear();
             lcd.print("   Card UID:    ");
             lcd.setCursor(0,1);
             for (byte i = 0; i < mfrc522.uid.size; i++) {
               card1[i] = aux[i];
             lcd.print( card1[i], DEC);
             lcd.print( " ");
             flag =1;
            }
           delay(3000);
           lcd.clear();
           lcd.print(" Apropie cardul");
           lcd.setCursor(0,1);
           lcd.print("  Pentru acces   ");
           } 

           else{
            
           
             for (byte i = 0; i < mfrc522.uid.size; i++) {
               if(aux[i] == card1[i])
                cnt++;
             }
                            
            if(cnt == mfrc522.uid.size-1)
            {
              lcd.clear();
              lcd.print("     ACCES     ");
              lcd.setCursor(0,1);
              lcd.print("     PERMIS    ");
              delay(200);

               myServo.write(180);
               delay(5000);
               myServo.write(0);
             }
             else
             {
              lcd.clear();
              lcd.print("     ACCES     ");
              lcd.setCursor(0,1);
              lcd.print("    INTERZIS     ");
              delay(2000);
             }
             
           }
           
           lcd.clear();
           lcd.print(" Apropie cardul");
           lcd.setCursor(0,1);
           lcd.print("  Pentru acces   ");
  cnt=0;
}

Credits

abiodun1991
6 projects • 3 followers
Contact

Comments

Please log in or sign up to comment.