Using an RFID Reader and tags we will create an access control system and a servo motor will open/close depending if the access is granted or not .
WORKING PROCEDURE
Active IR Sensors can emit IR radiation as well as detect it. In this project a remote transmits IR signals and an IR sensor receives it. The HEXADECIMAL code is noted down for each button pressed ,applied in the code and necessary commands are written to control the LEDs.Keep in Mind:
- A capacitor of 470uF must be used across the source to stop the jittering of the motor and make a smooth flow of the motor.
-
External battery sources must be used ! Here we have used 6v battery.
-
Resistors of at least 100 Ohms must be placed in series with the LEDs to avoid any damage to the LEDs.
THE COMPONENTS
- ARDUINO UNO BOARD
- LED:--> BLUE-RED [ according to your wish ]
-
RESISTOR 100 Ohms - X2
- 470uF CAPACITOR
- RFID MFRC522
- RFID TAG + KEY
- BUZZER
- BREAD BOARD
- SERVO SG90
- 6V DC POWER SUPPLY
- SOLDERING IRON
- GLUE GUN
-
JUMPER WIRES ( M-M | M-F )
SCHEMATIC
SCHEMATIC OF RFID ACCESS CONTROL SYSTEM
THE COMPLETE CODE
/*author : Sadman Alvee -> owner of impedancPlus*/
/* author- sadman alvee
* Owner/Founder @ impedancePlus
*/
#include <SPI.h>
#include <MFRC522.h>
#include <Servo.h>
//RFID_Sensor
/* must connect as follows :
RFID MODULE PIN ARDUINO UNO PIN
1. SCK pin 13
2. MOSI pin 11
3. MISO pin 12
4. IRQ X-EMPTY-X
*/
int resetPin = 9;
int ssPin = 10;
boolean systemState;
boolean access;
//Servo
int servoPin = 3;
int validAccessPos = 90;
int invalidAccessPos = 0;
//Signal
int redLedPin = 7;
int blueLedPin = 6;
int buzzerPin = 2;
//Creating object of type: Servo
Servo thisServo;
//Creating object of type: RFID Modulo
MFRC522 mfrc522(ssPin, resetPin);
void _ConfigureRFIDsensor() {
// Reset the loop if no new card present on the sensor/reader. This saves the entire process when idle.
if ( ! mfrc522.PICC_IsNewCardPresent()) {
systemState = false;
access = false;
_printData(systemState, access);
return;
}
// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial()) {
return;
}
String uniqueID = "";
byte letter;
for (int i = 0; i < mfrc522.uid.size; i++) {
uniqueID.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? "0" : " "));
uniqueID.concat(String(mfrc522.uid.uidByte[i], HEX));
}
uniqueID.toUpperCase();
if (uniqueID.substring(1) == "17 1F 72 63") { //UNIQUE ID OF THE CARD
systemState = true;
access = true;
_printData(systemState, access);
_ConfigureSignalSystem(access);
} else {
systemState = true;
access = false;
_printData(systemState, access);
_ConfigureSignalSystem(access);
}
// Dump debug info about the card; PICC_HaltA() is automatically called
//mfrc522.PICC_DumpToSerial(&(mfrc522.uid));
}
void _ConfigureServo(boolean access) {
if (access) {
thisServo.write(validAccessPos);
} else if (!access) {
thisServo.write(invalidAccessPos);
}
}
void _ConfigureSignalSystem(boolean access) {
if (access) {
digitalWrite(blueLedPin, HIGH);
digitalWrite(buzzerPin, HIGH);
_ConfigureServo(access);
delay(2500);
digitalWrite(blueLedPin, LOW);
digitalWrite(buzzerPin, LOW);
access = false;
_ConfigureServo(access);
} else if (!access) {
for (int i = 0; i < 10 ; i++) {
digitalWrite(redLedPin, HIGH);
digitalWrite(buzzerPin, HIGH);
delay(150);
digitalWrite(buzzerPin, LOW);
digitalWrite(redLedPin, LOW);
delay(150);
_ConfigureServo(access);
}
}
}
void _printData(boolean systemState, boolean access) {
if (systemState == true && access == true) {
Serial.println("ACCESS GRANTED");
Serial.println("");
delay(400);
} else if (systemState == true && access == false) {
Serial.println("ACCESS DENIED");
Serial.println("");
delay(400);
} else if (systemState == false && access == false) {
Serial.println(F("PLEASE HOLD YOUR CARD INFRONT OF THE READER"));
delay(500);
}
}
void setup() {
Serial.begin(9600); // Initialize serial communications with the PC
SPI.begin(); // Initialize SPI bus
mfrc522.PCD_Init(); // Initialize MFRC522
delay(4);
//mfrc522.PCD_DumpVersionToSerial(); // Show details of PCD - MFRC522 Card Reader details
thisServo.attach(servoPin);
thisServo.write(0); //Starting Servo angle - 0 degree
pinMode(redLedPin, OUTPUT);
pinMode(blueLedPin, OUTPUT);
pinMode(buzzerPin, OUTPUT);
}
void loop() {
_ConfigureRFIDsensor();
}
Comments
Post a Comment