Welcome to Hackster!
Hackster is a community dedicated to learning hardware, from beginner to pro. Join us, it's free!
issamyh
Published

Realization of an automatic barrier using an RFID badge

The project consists of raising and lowering an automatic barrier using an RFID badge.

BeginnerProtip165
Realization of an automatic barrier using an RFID badge

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
RFID reader (generic)
×1
RGB LCD Shield Kit, 16x2 Character Display
RGB LCD Shield Kit, 16x2 Character Display
×1
SG90 Micro-servo motor
SG90 Micro-servo motor
×1
LED (generic)
LED (generic)
×1
5 mm LED: Green
5 mm LED: Green
×1
Buzzer
Buzzer
×1

Story

Read more

Custom parts and enclosures

code programming

Schematics

circuit shematics

Code

code programming

C/C++
#include <MFRC522.h>
#include <Servo.h>
#include <SPI.h>
#include <LiquidCrystal.h>
#include<MFRC522Extended.h>
MFRC522 RFID(9,8);
LiquidCrystal lcd(7,6,2,3,4,5);
Servo  moteur ;
String code1="19 58 9a e" ;
String test; 
int i;


void setup() {

  SPI.begin();
  RFID.PCD_Init();
  lcd.begin(16,2);
  moteur.attach(8);
  moteur.write(0);
  pinMode(0,OUTPUT);
  pinMode(1,OUTPUT);
  pinMode(A1,OUTPUT);
  digitalWrite(0,LOW);
  digitalWrite(1,LOW);
}

void loop() {

   lcd.setCursor(0,0);
   lcd.print("  SMP - PFE -");
   lcd.setCursor(4,1);
   lcd.print("WELCOME");
   if(RFID.PICC_IsNewCardPresent()) 
  { 
    if(RFID.PICC_ReadCardSerial())
    {
        test="";  
        for(i=0;i<RFID.uid.size;i++)
        {
        test += String(RFID.uid.uidByte[i],HEX);
        test += " ";
        }

  if(test==code1){

    digitalWrite(1,HIGH);
    tone(A1,1000);
    delay(300);
    noTone(A1);
    lcd.clear();
    lcd.print("acces autorise");
    moteur.write(90);
   delay(1000);
    lcd.clear();
    lcd.print("bonjour Mr X");
    delay(2000);
    lcd.clear();

for (i=10;i>=0;i--)
        {
          lcd.print("Porte se fermera");
          lcd.setCursor(0,2);
          lcd.print("dans ");
          lcd.print(i);
          lcd.print(" secondes");
          delay(1000);
          lcd.clear();
        }
        tone(A1,1000);
        delay(300);
        noTone(A1);
        moteur.write(0); 
        digitalWrite(1,LOW);
      }
    
    
    else 
    {
       digitalWrite(0,HIGH);
        tone(A1,1000);
        lcd.clear();
        lcd.print("  Non reconnue");
        lcd.setCursor(0,2);
        lcd.print("  Acces refuse");
        delay(2000);
        lcd.clear();
        noTone(A1);
        digitalWrite(0,LOW);
    }
  }
  }
 }

Credits

issamyh
1 project • 0 followers
Contact

Comments

Please log in or sign up to comment.