Published using Google Docs
REPORT_INTEGRATED DOOR LOCK AND ENERGY SAVING SYSTEM
Updated automatically every 5 minutes

INTEGRATED DOOR LOCK

AND ENERGY SAVING SYSTEM

MINI PROJECT REPORT

Submitted in partial fulfillment of the

requirements for the award of Bachelor of Technology Degree

in Electronics and Communication Engineering

of APJ Abdul Kalam Technological University

By

AMAL ANIL KUMAR         (Reg No: MBT19EC018)

ANAMIKAA S NAIR                 (Reg No: MBT19EC021)

FAIZAN AHAMED                (Reg No: MBT19EC045)

NANDAN S                           (Reg No: MBT19EC072)

MBCET Emblem

DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING

MAR BASELIOS COLLEGE OF ENGINEERING & TECHNOLOGY

MAR IVANIOS VIDYA NAGAR, NALANCHIRA, THIRUVANANTHAPURAM, 695 015.

2022


DEPARTMENT OF

ELECTRONICS AND COMMUNICATION ENGINEERING

MAR BASELIOS COLLEGE OF ENGINEERING & TECHNOLOGY

MAR IVANIOS VIDYA NAGAR, NALANCHIRA, THIRUVANANTHAPURAM, 695 015

MBCET Emblem

CERTIFICATE

This is to certify that this mini project report entitled “INTEGRATED DOOR LOCK AND ENERGY SAVING SYSTEM” is a bonafide record of work done by AMAL ANILKUMAR, ANAMIKAA S NAIR, FAIZAN AHAMED  and NANDAN S of the sixth semester Electronics and Communication branch towards the partial fulfillment of the requirements for the award of Bachelor of Technology Degree in Electronics and Communication Engineering of APJ Abdul Kalam Technological University.

Guide        

        

Ms. Liya Johnson

Asst. Professor,

Dept. of ECE

MBCET

Coordinator        

        

Mr. Anoop K Johnson

Asst. Professor,

Dept. of ECE

MBCET

Head of the Department

        

Dr. Jayakumari J

Professor,

Dept. of ECE

MBCET

ACKNOWLEDGEMENT

With great enthusiasm and pleasure we are bringing out this project report here. We use this opportunity to express our heartiest gratitude to the support and guidance offered to us from various sources during the course of completion of our project.

We are also grateful to Dr. Jayakumari J, Professor, Head of the Department, Electronics and Communication Engineering, for her valuable suggestions.

It is our pleasant duty to acknowledge our Mini Project Co-coordinator, Mr. Anoop K Johnson, Assistant Professor in Department of Electronics and Communication Engineering, who has guided and given supervision for the project work.

Let us express our heartfelt gratitude to our guide, Ms.Liya Johnson, Assistant  Professor in ECE dept. for helping us all throughout the project.

Above all, we owe our gratitude to the Almighty for showering abundant blessing upon us.

We also express our wholehearted gratefulness to all our classmates who have expressed their views and suggestions about our projects and have helped us during the course of the project.

We extend our sincere thanks and gratitude once again to all those who helped us make this undertaking a success.


ABSTRACT

Every person should feel at ease in their daily lives. Access control on doors plays an important role in the concept of security. A password-based door lock system allows authorized persons to access protected areas. Traditional locks are not as secure as they used to be. Anyone can break in by picking these locks. A proper framework has to be implemented in order to provide 24*7 security and for that ATMEGA is used. Passwords are entered using a keypad, The entered password will be compared to the preset password, access will be granted with the door opening status being displayed on the LCD. If the password is incorrect, the door will remain closed and the LCD will display "wrong password". By replacing mechanical door locks with electronic door locks , the security door lock system promises a bold step into the future. An extra add on feature is its ability to check lights that are accidentally left on and turn them off if not necessary. The lighting system uses an PIR sensor to sense motion, if motion is not detected light will be off.


CONTENTS

  1. INTRODUCTION                                                                         1
  2. TECHNOLOGY IN GENERAL                                                         2

2.1        Block Diagram of Circuit                                                        2

2.2        Block Diagram Explanation                                                        3

2.2.1        ATMEGA 328                                                        4

2.2.2        LCD Display                                                                5

2.2.3        IR Sensor                                                                6

2.2.4        PIR sensor                                                                6

2.2.5        4*4 Matrix Keypad                                                        7

2.2.6        Servo motor                                                                8

  1. TECHNOLOGY IN SPECIFIC                                                        9

3.1        ATMEGA 328p                                                                9

3.2        IR Sensor                                                                        10

3.3        PIR sensor                                                                        11

3.4        POWER LED                                                                12

3.5         4*4 Matrix Keypad                                                                13

3.6        LCD Display                                                                        14

3.7        Servo motor                                                                        15

3.8        Crystal Oscillator        `                                                        16

3.9        PCB Dot Board                                                                17

3.10        28 pin IC Base                                                                18

3.11        5V Adapter                                                                        18

3.12        Resistor                                                                        19

3.13        Capacitor                                                                        20

3.14        Jumper wires                                                                        21

  1. HARDWARE IMPLEMENTATION                                                22

4.1        Circuit Diagram                                                                22

4.2        Working                                                                        23

4.3        List of Components                                                                23

4.4        Energy consumed by Components                                                24

  1. SOFTWARE IMPLEMENTATION                                                25

5.1        Flowcharts                                                                        

        5.1.1        Door Lock System                                                        25

        5.1.2        Energy saving System                                                26

5.2        Algorithms                                                                        27

  1. RESULTS                                                                                28
  2. CONCLUSION                                                                        29
  3. REFERENCES                                                                        30
  4.  APPENDIX                                                                                

9.1 Program                                                                                31

9.2 Data sheets                                                                        42


LIST OF FIGURES

  1. Fig 2.1 Block diagram of circuit                                                        2
  2. Fig 2.2.1 ATMEGA 328p                                                                4
  3. Fig 2.2.2 LCD Display                                                                5
  4. Fig 2.2.3 IR Sensor                                                                5
  5. Fig 2.2.4 PIR Sensor                                                                6
  6. Fig 2.2.5 Matrix Keypad                                                                6
  7. Fig 2.2.6 Servo motor                                                                7
  8. Fig 3.1 Pinout of ATMEGA 328p                                                8
  9. Fig 3.2 Pinout of IR sensor                                                         9
  10. Fig 3.3 Pinout of PIR sensor                                                         9
  11. Fig 3.4 POWER LED                                                                10
  12. Fig 3.5 Pinout of  4x4 Matrix Keypad                                                 11
  13. Fig 3.6 PinOut of LCD Display                                                        12
  14. Fig 3.7 Servo motor                                                                13
  15. Fig 3.8 Crystal Oscillator                                                                14
  16. Fig 3.9 PCB Dot board                                                                15
  17. Fig 3.10 28 pin IC base                                                                16
  18. Fig 3.11 5V Adapter                                                                16
  19. Fig 3.12 Resistor                                                                         16
  20. Fig 3.13 Capacitor                                                                17
  21. Fig 3.14 Jumper wires                                                                 16
  22. Fig 4.1 Circuit Diagram                                                                17
  23. Fig 5.1.1  Flow chart - Door Lock System                                        19
  24. Fig 5.1.2 Flow chart - Energy saving system                                        20
  25. Fig 6.1 Working Model                                                                28                                                                        

CHAPTER 1

INTRODUCTION

People are quite familiar with traditional lock systems because of its easy use and cheap cost. But this system has more cons than pros i.e - people have the tendency to lose the key which would in turn deny access to their property. Once given access (key) to a person, the person can easily make a duplicate of the key which would invade their privacy and no longer can have complete access control. People have to lug keys around which again gives the possibility of losing the key. The listed cons can be overlooked and can be improvised by the application and the implementation of digital door lock system (password based).

Digital door lock systems can be keypad based, biometric based or smart cards based. These systems are more prominent and effective in public places (hospitals, offices, schools), because it provides maximum security since it can be reprogrammed and is of friendly  budget. It eliminates the need for security all day long and we can programme it to be active after office hours. Also it is more practical than handing out keys to people.

Individuals often forget to switch off lights, appliances when left unused which results in high electricity bills and energy wastage. Energy wastage mainly occurs due to improper use and maintenance of devices.

This project aims to provide complete security to our residents with the application of password based door lock system and with the implementation of IR sensor and PIR sensor ,energy efficiency can be optimized.

CHAPTER 2

TECHNOLOGY IN GENERAL

BLOCK DIAGRAM

fig. 2.1 Block diagram of circuit

BLOCK DIAGRAM EXPLANATION

A digital code lock system is made using ATMEGA 328, which provides load control control. It is a simple embedded system that accepts keyboard input and the output is controlled accordingly. This system demonstrates a password-based door lock system using an ATMEGA 328, where upon entering the correct code or password, the door opens and the affected person is allowed access to a secure area. If another person arrives, they will ask to re-enter the password. If the password is wrong, then the door will remain locked, denying the person access. The main component in the circuit is an ATMEGA 328, which is basically used to send a text message to the homeowner about a security breach. The 4* 4 keyboard is used to enter the password. The entered password is compared with a known password. If the password is correct, the system will open the door with the servo motor and display the door status on the LCD. If the password is wrong, the door will remain closed and "WRONG PASSWORD" will be displayed on the LCD. In addition, we use PIR sensor and IR sensor to realize energy saving applications. PIR sensor detects motion in the room while IR is kept at the entrance of the room to turn off the light.

ATMEGA 328p

fig 2.2.1 ATMEGA 328p

ATmega328 is a micro-controller that is commonly used in Arduino development boards such as Arduino Uno, Arduino Pro Mini etc. The Atmel ATmega328P is a low-power CMOS 8-bit microcontroller based on the AVR-enhanced RISC architecture. The ATmega328P delivers close to 1 MIPS per MHz throughput by executing powerful instructions in a single clock cycle, allowing system designers to optimize power consumption and processing speed. ATmega328 generally comes in different packages i.e - ATmega328 AU, ATmega328 AUR, ATmega328 MMH etc. ATmega328 has both programmable and non- programmable memory and it also provides static operation.

LCD Display

fig 2.2.2 LCD Display

A liquid crystal display (LCD) is a flat panel or other modulated display that uses a liquid crystal in combination with a polarizer to modulate light. The LCD does not emit light directly, but instead uses a backlight or reflector to create color and monochrome images.  It has two rows with each row capable of displaying 16 different characters. This LCD display can work in both 4-bit and 8-bit modes. Each character in the row can be built using a 5x8 pixel box. LCD displays are commonly available with green and blue backlights.

IR SENSOR

 

fig 2.2.3 IR Sensor

An infrared sensor (IR sensor) is a radiation-sensitive optoelectronic component with a spectral sensitivity in the infrared wavelength range 780 nm - 50 µm.

PIR SENSOR

fig 2.2.4 PIR Sensor

The Passive Infrared Sensor (PIR) sensor module is used for motion detection.

4X4 Matrix keypad

fig 2.2.5 Matrix Keypad

The 4*4 matrix of this component is used to insert input values ​​into the project. The component has a total of eight terminals controlled by the module's 16 buttons. In the eight terminals, four are ROWS OF MATRIX and the other four are COLUMNS OF MATRIX. It has an ultra thin design and easy to use interface.

Servo Motor

fig 2.2.6 Servo Motor

Servo motors are rotary or linear actuators that enable for the accurate position, velocity, and acceleration control. They are made consisting of an appropriate motor and a position feedback sensor. The servo is operated by sending pulses of variable width through the control wire, often known as pulse width modulation (PWM). Servo motors are made up of a simple motor which runs through a servo mechanism.

CHAPTER 3

TECHNOLOGY IN SPECIFIC

ATMEGA 328

fig 3.1 Pinout of ATMEGA 328p

The high-performance Microchip 8-bit AVR® RISC-based microcontroller combines 32 KB ISP Flash memory with read-while-write capabilities, 1 KB EEPROM, 2 KB SRAM, 23 general purpose I/O lines, 32 general purpose working registers, three flexible timer/counters with compare modes, internal and external interrupts, serial programmable USART, a byte-oriented Two-Wire serial interface, SPI serial port, 6-channel 10-bit A/D converter (8-channels in TQFP and QFN/MLF packages), programmable watchdog timer with internal oscillator, and five software selectable power saving modes. The device operates between 1.8 - 5.5 V.

IR SENSOR

 

fig 3.2 Pinout of IR Sensor

An infrared sensor (IR sensor) is a radiation-sensitive optoelectronic component with a spectral sensitivity in the infrared wavelength range 780 nm - 50 µm. IR sensors are now widely used in motion detectors, which are used in building services to switch on lamps or in alarm systems to detect unwelcome guests.

PIR SENSOR

fig 3.3 Pinout of PIR Sensor

The Passive Infrared Sensor (PIR) sensor module is used for motion detection. It is often referred to as a "PIR", "Pyroelectric", "Passive Infrared" and "IR Motion" sensor. The module has an on-board pyroelectric sensor, conditioning circuitry and a dome shaped Fresnel lens. It is used to sense movement of people, animals, or other objects. They are commonly used in burglar alarms and automatically-activated lighting systems.

POWER LED

fig 3.4 POWER LED

A light emitting diode (LED) is a semiconductor light source that emits light when an electric current flows through it. The electrons in the semiconductor recombine with holes and emit energy in the form of photons (packets of energy). The color of light (corresponding to the energy of photons) is determined by the energy required for the electrons to pass through the bandgap of the semiconductor. White light is obtained by using layers of luminescent phosphorescent material on multiple semiconductors or semiconductor devices.

4X4 Matrix Keypad

fig 3.5 Pinout of 4x4 Matrix Keypad

The 4*4 matrix of this component is used to insert input values ​​into the project. The component has a total of eight terminals controlled by the module's 16 buttons. It has a maximum rating of 24 VDC and 30mA. This can generally operate under temperatures from 0 to 50℃. Matrix keyboards are the most commonly used input devices in many application areas such as digital circuits, telephone communications, calculators and ATMs. A matrix keyboard consists of a series of push buttons or switches arranged in a matrix of rows and columns.

LCD Display

fig 3.6 Pinout of LCD Display

A liquid crystal display (LCD) is a flat panel or other modulated display that uses a liquid crystal in combination with a polarizer to modulate light. The LCD does not emit light directly, but instead uses a backlight or reflector to create color and monochrome images.16x2 LCD display is capable of displaying 16 characters in 2 lines. It has a built-in  ST7066 or equivalent controller. The liquid crystal display consists of several layers, including two polarizing panel filters and electrodes. LCD technology is used to display images on other electronic devices such as notebooks and minicomputers. Light is projected onto the liquid crystal layer by the lens. The combination of this colored light and the grayscale image of the crystal (formed as the current passes through the crystal) forms the colored image.

Servo Motor

fig 3.7 Servo Motor

Servomotors are rotary or linear actuators that enable for the accurate position, velocity, and acceleration control. They are made consisting of an appropriate motor and a position feedback sensor. The servo is operated by sending pulses of variable width through the control wire, often known as pulse width modulation (PWM).There is a need for a  sophisticated controller. In many cases, a dedicated module designed specifically for  is required. The term servomotor is often used to refer to a motor suitable for use in closed-loop control systems.

Crystal Oscillator

fig 3.8 Crystal Oscillator

The frequency stability of the output signal can be significantly improved by proper selection of the components used in the resonant feedback circuitry, including the amplifier. When a voltage source is applied to a small, thin piece of quartz, it begins to change shape, creating a property called the piezoelectric effect. This piezoelectric effect is a characteristic of a crystal in which an electric charge produces a mechanical force by changing the shape of the crystal, or vice versa, and the mechanical force applied to the crystal produces an electric charge. Piezoelectric devices can then be classified as transducers because they convert one type of energy into another type of energy (electric to mechanical, or mechanical to electrical). This piezoelectric effect produces mechanical vibrations or vibrations that can be used to replace the standard LC tanks of previous oscillators.

PCB Dot Board

fig 3.9 PCB Dot board

PCB Dot Boards are materials for prototyping electronic circuits (also known as DOT PCBs or perfboards). This is a thin, hard plate that is pre-drilled at standard intervals throughout the grid. Square grids are typically spaced 0.1 inches (2.54 mm) apart. These holes are surrounded by round or square copper pads, but bare boards are also available. Inexpensive performance boards have pads on only one side of the board, while high quality performance boards have pads on both sides (plated through holes). Each pad is electrically insulated, so the builder uses wire wrap or miniature point-to-point wiring techniques to make all connections. Discrete components such as resistors, capacitors and integrated circuits are soldered to the prototype board.

28pin Ic Base

fig 3.10 28 pin IC Base

It is a standard 28-pin IC base that allows the user to connect the IC to the circuit. IC sockets are typically used to prevent damage to the IC when soldering and testing multiple circuits. They are made of black thermoplastic and tin-plated alloy contacts. There is a notch on one end for easy identification.

5V Adapter

fig 3.11 5V Adapter

An AC adapter, AC / DC adapter, or AC / DC converter is a type of external power source, often housed in a housing similar to an AC plug. Adapters for battery-powered devices are sometimes referred to as chargers or chargers. Power supplies are used in electrical equipment that requires power but does not include the internal components to obtain the required voltage and power from the mains. The internal circuitry of an external power supply is very similar to the design used for an internal or internal power supply.

Resistor

fig 3.12 Resistor

A resistor is a passive electrical component with two terminals that creates electrical resistance. In electronic circuits, resistors are commonly used to reduce current flow, adjust signal levels, to divide voltages and to terminate transmission lines among others. Higher power resistors are used to dissipate many watts of power as heat. Electric function of resistor is to provide a known resistance to the circuit.

Capacitor

fig 3.13 Capacitor

The main purpose of a capacitor is to store electrostatic energy in an electric field and, if possible, supply this energy to the circuit. To prevent dangerous circuit failures, AC current flows, but DC does not. 

When connected to a charging circuit, capacitors can store electrical energy. Also, when removed from the charging circuit, it consumes stored energy and can be used as a temporary battery.

Jumper wires

fig 3.14 Jumper wires

Jumpers are small metal connectors used to open and close parts of electrical circuits. The primary function of these components is to connect the various components of a circuit without soldering.

CHAPTER 4

HARDWARE IMPLEMENTATION

CIRCUIT DIAGRAM

fig 4.1 Circuit Diagram

WORKING

 

This system demonstrates a password-based door lock system using an ATMEGA 328, where upon entering the correct code or password, the door opens and the affected person is allowed access to a secure area. If another person arrives, they will ask to re-enter the password. If the password is wrong, then the door will remain locked, denying the person access. The main component in the circuit is an ATMEGA 328, which is basically used to send a text message to the homeowner about a security breach. The 4* 4 keyboard is used to enter the password. The entered password is compared with a known password. If the password is correct, the system will open the door with the servo motor and display the door status on the LCD. If the password is wrong, the door will remain closed and "WRONG PASSWORD" will be displayed on the LCD. In addition, we use PIR sensor and IR sensor to realize energy saving applications. PIR is placed in a room, where it detects motion, led thereby glows, when presence is not detected by the PIR, led will turn off. IR used at the exit, when no one is present at home, it turns off the light.

COMPONENT LIST

ENERGY CONSUMED BY COMPONENTS

CHAPTER 5

SOFTWARE IMPLEMENTATION

FLOW CHART

Door Lock System

fig 5.1.1 Flow chart - Door Lock System

Energy saving system

fig 5.1.1 Flow chart - Energy saving system

ALGORITHM

Door Lock System

Step 1 - Start

Step 2 - Enter the password

Step 3 - Check the password , if wrong go to step 2 ,else Step 4

Step 4 -  Displays Access granted, door gets unlocked

Step 5 - Door gets locked again, go to step 2

Energy saving system

Step 1 - Start

Step 2 - PIR taken as input

Step 3 - If motion detected, LED turned ON

Step 4 -  If motion not detected, LED remains OFF

Step 5 - Go to step 2


CHAPTER 6

RESULT

Integrated door lock and energy saving system worked in an efficient way. The door  was secured with the password and access was granted when the correct password was detected and energy consumption was also reduced.

fig 6.1 Working Model

CHAPTER 7

CONCLUSION

This project ‘INTEGRATED DOOR LOCK AND ENERGY SAVING SYSTEM is designed and implemented using a keypad and ATMEGA 328. The Atmega compares the password with the default password. The servo motor will rotate according to password and a corresponding message will appear on the LCD display. After entering the password, the door will open correctly as the default password that was set. It is very useful for people looking for more secure doors and cabinets. Mechanical and these techniques use both electronic components, making them highly efficient. Password based door lock systems will provide maximum security so that users are able to fully satisfy their needs. Meantime, an individual can afford to buy a door locking system with minimal cost to keep their valuables safe.

The model currently being designed is the first practical prototype of the targeted product, and we are also working on improving the machine by incorporating the following regulations in the future:


REFERENCES

  1. D. Aswini, R. Rohindh, K. S. Manoj Ragavendhara and C. S. Mridula, "Smart Door Locking System," 2021 International Conference on Advancements in Electrical, Electronics, Communication, Computing and Automation (ICAECA), 2021, pp. 1-5, doi: 10.1109/ICAECA52838.2021.9675590.
  2. S. Shetty, S. Shetty, V. Vishwakarma and S. Patil, "Review Paper on Door Lock Security Systems," 2020 International Conference on Convergence to Digital World - Quo Vadis (ICCDW), 2020, pp. 1-4, doi: 10.1109/ICCDW45521.2020.9318636.
  3. https://www.electronicshub.org/password-based-door-lock-system-using-8051-microcontroller/
  4. https://www.electronicshub.org/automatic-room-lighting-system-using-microcontroller/
  5. https://components101.com/sensors/hc-sr501-pir-sensor
  6. https://components101.com/sensors/ir-sensor-module
  7. https://components101.com/displays/16x2-lcd-pinout-datasheet
  8. https://datasheetspdf.com/mobile/1469778/ATMEL/ATmega328P/1
  9. GitHub - kmhmubin/Password-based-doorlock-system-in-8051-microprocessor: Password-based door lock system using 8051/PIC microcontroller
  10. https://www.researchgate.net/publication/345025801_Design_and_Construction_of_Microcontroller_Based_Password_Enabled_Door_Lock_System_Design_and_Construction_of_Microcontroller_Based_Password_Enabled_Door_Lock_System January 2019
  11. https://www.irjmets.com/uploadedfiles/paper/volume_3/issue_11_november_2021/17170/final/fin_irjmets1637256275.pdf


APPENDIX

Program

#include <LiquidCrystal.h>

#include <Servo.h>

#include <Keypad.h>

LiquidCrystal lcd(A0,A1,A2,A3,A4,A5); ///RS,EN,D4,D5,D6,D7

#define password_length 6

char newcode[password_length];

char changecode[password_length]="#####";

char passcode[password_length] ="*1234";   /// password

char data[password_length];        ///input password

char key;

byte data_count = 0,passcode_count = 0,newdata_count=0;

Servo myservo;

int pos = 0;

int enter=0;

const byte ROWS = 4;  

const byte COLS = 4;  

char keys[ROWS][COLS] = {

  {'1','2','3','A'},

  {'4','5','6','B'},

  {'7','8','9','C'},

  {'*','0','#','D'}

};

#define IR 0   /// IR

#define PIR1 1  ///PIR 1

#define PIR2 2  /// PIR 2

#define LED1 3  ///LED 1

#define LED2 4  /// LED 2

bool door = true;

byte rowPins[ROWS] = { 5, 6, 7, 8 };

byte colPins[COLS] = { 9, 10, 12, 13 };

Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

void setup() {

  lcd.begin(16, 2);

  myservo.attach(11);   //// servo motor pin 11

  myservo.write(0);

  lcd.print("Smart Pass Lock ");

  lcd.setCursor(0, 1);

  lcd.print("     System     ");

  pinMode(IR,INPUT);

  pinMode(PIR1,INPUT);

  pinMode(PIR2,INPUT);

  pinMode(LED1,OUTPUT);

  pinMode(LED2,OUTPUT);

  digitalWrite(LED1, LOW);

  delay(20);

  digitalWrite(LED2, LOW);

  delay(300);

  lcd.setCursor(0, 0);

  lcd.print(" Enter Password ");

  lcd.setCursor(0, 1);

  lcd.print("                ");

  delay(100);

}

void loop()

 {

  if(enter>0 && digitalRead(IR) == LOW)

  {

    //digitalWrite(LED1, LOW);

    //delay(20);

    //digitalWrite(LED2, LOW);

    //delay(20);

    lcd.clear();

    ServoOpen();

    ServoClose();

    delay(100);

    enter--;

  }

  if(enter>0)

  {

    if(digitalRead(PIR1) == LOW)

    {

      digitalWrite(LED1, HIGH);  // turn LED1 ON

      delay(100);

      }

    if(digitalRead(PIR1) == HIGH)

    {

      digitalWrite(LED1, LOW);  // turn LED1 OFF

      delay(20);

      }

    if(digitalRead(PIR2) == LOW)

    {

      digitalWrite(LED2, HIGH);   // turn LED2 ON

      delay(10);

      }

    if(digitalRead(PIR2) == HIGH)

    {

      digitalWrite(LED2, LOW); // turn LED2 OFF

      delay(20);

      }    

    }

  if(enter==0 && door ==0)

  {

    lcd.clear();

    lcd.setCursor(0, 0);

    lcd.print("    NO PERSON   ");

    lcd.setCursor(0, 1);

    lcd.print("     INSIDE     ");

    delay(300);

    door=true;

    }  

  if(kpd.getKey() != NO_KEY)

  {

    Open();

    }

 }

void clearData()

{

  while (data_count != 0)

  {

   data[data_count--] = 0;

  }

  return;

}

void clearnewData()

{

  while (newdata_count != 0)

  {

   newcode[newdata_count--] = 0;

  }

  return;

}

void ServoOpen()

{

  for (pos = 0; pos <= 110; pos += 1) {

    myservo.write(pos);              

    delay(15);                       // waits 15ms for the servo to reach the position

  }

  lcd.clear();

  lcd.setCursor(0, 1);

  lcd.print("  Door Open..!! ");

  delay(300);

}

void ServoClose()

{

  for (pos = 110; pos >= 0; pos -= 1) {

    myservo.write(pos);              

    delay(15);                      // waits 15ms for the servo to reach the position

  }

  lcd.clear();

  lcd.setCursor(0, 1);

  lcd.print("Door Closed..!! ");

  delay(200);

}

void Open()

{ lcd.clear();

  lcd.setCursor(0, 0);

  lcd.print(" Enter Password ");

  while (data_count < password_length -1)

  {

    key = kpd.getKey();

  if (key != NO_KEY) // makes sure a key is actually pressed

  {

    data[data_count] = key; // store char into data array

    lcd.setCursor(data_count, 1); // move cursor to show each new char

    lcd.print("*");

    data_count++;

  }

    }

    if (!strcmp(data, passcode))

    {

      lcd.clear();

      lcd.setCursor(0, 0);

      lcd.print("Access Granted!!");

      clearData();

      ServoOpen();

      delay(100);

      ServoClose();

      enter++;

      door = 0;

    }

    else if (!strcmp(data, changecode))

    {

      lcd.clear();

      lcd.setCursor(0, 0);

      lcd.print(" Enter current  ");

      lcd.setCursor(0, 1);

      lcd.print("    Password    ");

      delay(300);

      lcd.clear();

      clearData();

      while (data_count < password_length -1)

      {

      key = kpd.getKey();

      if (key != NO_KEY) // makes sure a key is actually pressed

      {

      data[data_count] = key; // store char into data array

      lcd.setCursor(data_count, 1); // move cursor to show each new char

      lcd.print("*");

      data_count++;

       }

        }

        if (!strcmp(data, passcode))

        {        

         clearData();

         lcd.clear();

         lcd.setCursor(0, 0);

         lcd.print(" Enter new pin  ");

         newdata_count=0;        

         while (newdata_count < password_length -1)

         {

          key = kpd.getKey();

          if (key != NO_KEY) // makes sure a key is actually pressed

          {

           newcode[newdata_count] = key; // store char into data array

           lcd.setCursor(newdata_count, 1); // move cursor to show each new char

           lcd.print("*");

           newdata_count++;

           }

          }

         lcd.clear();

         lcd.setCursor(0, 0);

         lcd.print("Confirm new pin ");

         clearData();

         data_count=0;

         while (data_count < password_length -1)

         {

          key = kpd.getKey();

          if (key != NO_KEY) // makes sure a key is actually pressed

          {

           data[data_count] = key; // store char into data array

           lcd.setCursor(data_count, 1); // move cursor to show each new char

           lcd.print("*");

           data_count++;

           }

          }

          if(!strcmp(data, newcode))

          { lcd.clear();

            lcd.setCursor(0, 0);

            lcd.print("  New pin set   ");

            delay(100);

            newdata_count=0;

            while (newdata_count < password_length -1)

            {

             passcode[newdata_count] = newcode[newdata_count];

             newdata_count++;

             }

            clearData();

            clearnewData();

            }

          else

          {   lcd.clear();

              lcd.setCursor(0, 0);

              lcd.print("Pins donot match");

              clearData();

              clearnewData();

            }

           

         }

         else

         {

          lcd.clear();

          lcd.setCursor(0, 0);

          lcd.print(" Wrong Password ");

          delay(100);

          door = 1;

          clearData();

          }

     }

    else

    {

      lcd.clear();

      lcd.setCursor(0, 0);

      lcd.print(" Wrong Password ");

      delay(100);

      door = 1;

      clearData();

    }

  }

DATASHEETS

ATMEGA 328p






LCD DISPLAY

 

PIR SENSOR

IR SENSOR

KEYPAD