Iotexp 8

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

EXPERIMENT - 8

Student Name: ARADHIKA UID: 22BCS15907


Branch: CSE Section/Group: 622-B
Semester: 5 Date of Performance: 11.10.24
Subject Name: IOT LAB Subject Code: 22CSP-329

1. Aim: To Create a Smart door lock system-using RFID.


2.Objective:
A door security system is used to stop unauthorized people to get access to a room or a building.
Such system is very useful if you have important data, information, and research stored in a
computer or in a bundle of files.
3.Input/Equipment Used:
1. RFID
2. LCD
3. I2C module
4. Servomotor
5. Door lock
6. Jumper Wires

4.Script:
This system is very useful in the Military, Research Centers, Banks, Server rooms, Jails,
Government offices, and Nuclear Plants. It prevents large destruction and loss.
1. Arduino Uno: We will use Arduino due to its easy use. It also provides several digital pins to
interface with the servomotor and RFID module at the same time. It is very friendly when you
prototyping any project.
2. RFID RC522: This module is based on MFRC522 IC which is used in contactless
communication. It is used both as a reader and a writer.
3. SG-90 Servo Motor: SG90 is a low-cost and high output power servo motor. In this project,
servo motor is used to indicate that the door is opening and closing. It is easy to use and program
and also provides precise movement. Learn more about servo at servo motor interfacing with
Arduino
4. 16×2 LCD: 16×2 LCD is used to display 16 text/characters in two lines. It has a total of 16 pins.
A 10K ohm potentiometer is connected with pin three to set the contrast of the LCD. It also contains
a backlight LED. In this project, LCD is used to show messages.
Code-
#include <deprecated.h>
#include <MFRC522.h>
#include <MFRC522Debug.h>
#include <MFRC522Extended.h>
#include <MFRC522Hack.h>
#include <require_cpp11.h>
#include<RFID.h>
#include <SPI.h>
#include <Servo.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
Servo myservo; // create servo object to control a servo
#define val0 117 // chnage the value according to token no
#define val1 134
int pos = 0;
/* Define the DIO used for the SDA (SS) and RST (reset) pins. */
#define SDA_DIO 10
#define RESET_DIO 9
RFID RC522(SDA_DIO, RESET_DIO);
void setup()
{
myservo.attach(8);
Serial.begin(9600);
/* Enable the SPI interface */
SPI.begin();
/* Initialise the RFID reader */
RC522.init();
lcd.begin(16, 2);
}
void loop()
{
byte i = 0;
int ID;
if (RC522.isCard())
{
RC522.readCardSerial();
Serial.println(RC522.serNum[i], DEC);
Serial.println("Card detected:");
ID = RC522.serNum[0];
}
delay(500);
if ( val0 == ID)
{ lcd.clear();
lcd.print("Access Granted");
lcd.setCursor(0, 1);
lcd.print("Welcome Haris");
delay(1800);
lcd.clear();
lcd.print("Door Opening");
delay(1500);
for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
// in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
delay(5000);
lcd.clear();
lcd.print("Door Closing");
delay(1500);
for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
}
else
{
lcd.clear();
lcd.print("Door Security ");
lcd.setCursor(0, 1);
lcd.print("System ");
}
if ( val1 == ID)
{ lcd.clear();
lcd.print("Access Granted");
lcd.setCursor(0, 1);
lcd.print("Welcome Bilal");
delay(1800);
lcd.clear();
lcd.print("Door Opening");
delay(1500);
for (pos = 0; pos <= 180; pos += 1) {
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position}
delay(5000);
lcd.clear();
lcd.print("Door Closing");
delay(1500);
for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); } }
else {
lcd.clear();
lcd.print("Door Security ");
lcd.setCursor(0, 1);
lcd.print("System "); }
}
5. Learning Outcomes:
• Learned RFID tags are lighter and cheaper than other types of tags, and they don't require a
battery.
• RFID door locks can increase security by limiting access to authorized personnel and
reducing the chance of unauthorized entry.
• RFID door locks eliminate the need for physical keys, allowing users to gain entry by
presenting RFID cards or tags to the reader.

You might also like