Forum

Incuietoare Electro...
 

Incuietoare Electromagnetica cu RFID  

  RSS

admin
(@admin)
Member Admin
Joined: 1 an ago
Posts: 3
12/09/2019 5:12 pm  

Acest proiect foloseste o placa de dezvoltare Nano impreuna cu un kit RFID si o incuietoare pentru un sistem de control acces cu cartela.

Proiectul functioneaza prin programarea placii Nano sa actioneze un releu, care la randul lui deschide alimentarea catre incuietoare, doar atunci cand cardul apropriat de modulul RFID este cel scris in cod. Foloseste de asemenea feedback vizual prin cele 2 leduri si auditiv prin modulul buzzer.

 

Piese necesare:

Incuietoare electromagnetica ( https://www.sigmanortec.ro/Incuietoare-Electromagnetica-12V-p148570052 )

Nano V3 ( https://www.sigmanortec.ro/Placa-dezvoltare-NANO-v3-AtMega-328p-compatibil-Arduino-p125419682 )

Releu Low Level ( https://www.sigmanortec.ro/Modul-Releu-comanda-5v-Low-Level-p125419766 )

Leduri ( https://www.sigmanortec.ro/LED-5mm-p131753270 )

fire dupont ( https://www.sigmanortec.ro/40-Fire-Dupont-30cm-p126421578 )

Buzzer pasiv ( https://www.sigmanortec.ro/Modul-Buzzer-pasiv-p126182521 )

Breadboard ( https://www.sigmanortec.ro/Breadboard-830-puncte-MB-102-p125923983 )

Sursa 9V ( https://www.sigmanortec.ro/Sursa-alimentare-Arduino-jack-p126029436 )

Rezistor 220 ohmi pentru leduri ( https://www.sigmanortec.ro/Rezistor-p126025265 )

Conector Mama ( https://www.sigmanortec.ro/Conector-2-1-x-5-5-Mama-cu-surub-p140901390 )

 

 

DESCARCA ARDUINO IDE AICI

DESCARCA LIBRARII AICI (se extrage arhiva in folderul Documente-->Arduino-->Libraries):

MFRC522.h

LiquidCrystal_I2C.h

COD 

COD ARDUINO IDE:

 

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

// Creare instante
LiquidCrystal_I2C lcd(0x27, 16, 2);
MFRC522 mfrc522(10, 9); // mfrc522(SS_PIN, RST_PIN)

// Initializare pini leduri, buzzer si releu incuietoare

constexpr uint8_t ledverde = 7;
constexpr uint8_t ledrosu = 6;
constexpr uint8_t releu = 8;
constexpr uint8_t buzzer = 5;

 

String tagUID = "76 A8 E7 FB"; // UID tag acceptat (de inlocuit cu UID cartela proprie)
String TagUID2 = "72 C6 7D 1F"; // inca un tag acceptat (daca se doreste mai mult de o cartela)
uint8_t i = 0; // variabila counter

void setup() {
// Configurare pini Arduino
pinMode(buzzer, OUTPUT);
pinMode(ledrosu, OUTPUT);
pinMode(ledverde, OUTPUT);
pinMode(releu, OUTPUT);

digitalWrite(releu, HIGH);
digitalWrite (buzzer, HIGH);

lcd.begin(); // initializare ecran
lcd.backlight();
SPI.begin(); // Initializare bus SPI
mfrc522.PCD_Init(); // Initializare rfid mfrc522

lcd.clear(); // Sterge ecran
}

void loop() {

lcd.setCursor(0, 0);
lcd.print(" Incuietoare");
lcd.setCursor(0, 1);
lcd.print(" Scaneaza Brelocul ");

// Cauta carduri
if ( ! mfrc522.PICC_IsNewCardPresent()) {
return;
}

// Selecteaza un card
if ( ! mfrc522.PICC_ReadCardSerial()) {
return;
}

//Reading from the card
String tag = "";
for (byte j = 0; j < mfrc522.uid.size; j++)
{
tag.concat(String(mfrc522.uid.uidByte[j] < 0x10 ? " 0" : " "));
tag.concat(String(mfrc522.uid.uidByte[j], HEX));
}
tag.toUpperCase();

//Checking the card
if (tag.substring(1) == tagUID || tag.substring(1)==TagUID2)
{
// If UID of tag is matched.
lcd.clear();
lcd.print("Acces Permis");
digitalWrite(ledverde, HIGH);
digitalWrite(buzzer, LOW);
delay(50);
digitalWrite(buzzer, HIGH);
delay(50);
digitalWrite(buzzer, LOW);
delay(50);
digitalWrite(buzzer, HIGH);
delay(50);
digitalWrite(buzzer, LOW);
delay(50);
digitalWrite(buzzer, HIGH);
delay(50);
digitalWrite(buzzer, LOW);
delay(50);
digitalWrite(buzzer, HIGH);
delay(50);
digitalWrite(buzzer, LOW);
delay(50);
digitalWrite(buzzer, HIGH);
delay(1000);
digitalWrite(releu, LOW);
delay(4000);
digitalWrite(ledverde, LOW);
digitalWrite(releu, HIGH);
lcd.clear();

}

else
{
// If UID of tag is not matched.
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Acces Respins");
lcd.setCursor(0, 1);
lcd.print("Card Incorect");
digitalWrite(buzzer, LOW);
digitalWrite(ledrosu, HIGH);
delay(2000);
digitalWrite(buzzer, HIGH);
digitalWrite(ledrosu, LOW);
lcd.clear();
}
}

 

 

COD CITIRE UID CARD:

#include <RFID.h>

/*
* Read a card using a mfrc522 reader on your SPI interface
* Pin layout should be as follows (on Arduino Uno):
* MOSI: Pin 11 / ICSP-4
* MISO: Pin 12 / ICSP-1
* SCK: Pin 13 / ISCP-3
* SS/SDA: Pin 10
* RST: Pin 9
*/

#include <SPI.h>
#include <RFID.h>

#define SS_PIN 10
#define RST_PIN 9

RFID rfid(SS_PIN,RST_PIN);

int led = 7;
int power = 8;
int serNum[5];
int cards[][5] = {
{118,168,231,251,194}

};

bool access = false;

void setup(){

Serial.begin(9600);
SPI.begin();
rfid.init();

pinMode(led, OUTPUT);

digitalWrite(led, LOW);

}

void loop(){

if(rfid.isCard()){

if(rfid.readCardSerial()){
Serial.print(rfid.serNum[0]);
Serial.print(" ");
Serial.print(rfid.serNum[1]);
Serial.print(" ");
Serial.print(rfid.serNum[2]);
Serial.print(" ");
Serial.print(rfid.serNum[3]);
Serial.print(" ");
Serial.print(rfid.serNum[4]);
Serial.println("");

for(int x = 0; x < sizeof(cards); x++){
for(int i = 0; i < sizeof(rfid.serNum); i++ ){
if(rfid.serNum[i] != cards[x][i]) {
access = false;
break;
} else {
access = true;
}
}
if(access) break;
}

}

if(access){
Serial.println("Welcome!");
digitalWrite(led, HIGH);
delay(1000);
digitalWrite(led, LOW);
digitalWrite(power, HIGH);
delay(1000);
digitalWrite(power, LOW);

} else {
Serial.println("Not allowed!");
digitalWrite(led, HIGH);
delay(500);
digitalWrite(led, LOW);
delay(500);
digitalWrite(led, HIGH);
delay(500);
digitalWrite(led, LOW);
}
}

rfid.halt();

}

 

 

DIAGRAMA CIRCUIT ATASAT

This topic was modified 3 luni ago 3 times by admin

Quote
Topic Tags
Share:

Please Login or Register