Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino UNO Based Smart Door Lock with Flame Detection and IR Remote Control

View and Edit Project In Cirkit DesignerImage of Arduino UNO Based Smart Door Lock with Flame Detection and IR Remote Control

Circuit Documentation

Summary

This circuit is designed to control a door lock system with various features including a keypad for password input, an LCD display for user interaction, a servo motor to actuate the lock mechanism, a flame sensor for safety, a piezo buzzer for audio feedback, and an IR receiver for remote control capabilities. The brain of the circuit is an Arduino UNO microcontroller which manages input from the keypad and flame sensor, drives the servo, displays information on the LCD, and responds to IR signals.

Component List

Arduino UNO

LCD Display 16x4 I2C

Servo

Flame Sensor

Piezo Buzzer

VS1838B IR Receiver

4X4 Membrane Matrix Keypad

Wiring Details

Arduino UNO

LCD Display 16x4 I2C

Servo

Flame Sensor

Piezo Buzzer

VS1838B IR Receiver

4X4 Membrane Matrix Keypad

Documented Code

//door
#include <Servo.h>
#include <LiquidCrystal_I2C.h>
#include <Keypad.h>
#include <Password.h>

Servo servo;
LiquidCrystal_I2C lcd(0x27, 16, 2);
String newPasswordString; //hold the new password
char newPassword[6]; //charater string of newPasswordString
byte a = 5;
bool value = true;
Password password = Password("0123"); //Enter your password
byte maxPasswordLength = 6;
byte currentPasswordLength = 0;
const byte ROWS = 4; // Four rows
const byte COLS = 4; // Four columns
char keys[ROWS][COLS] = {
  {'D', 'C', 'B', 'A'},
  {'#', '9', '6', '3'},
  {'0', '8', '5', '2'},
  {'*', '7', '4', '1'},
};
byte rowPins[ROWS] = {2, 3, 4, 5};
byte colPins[COLS] = {6, 7, 8, 9};
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

//flame sensor
int pinA1 = A1;
int pinD11 = 11;
int buzz = 12;
int flameA1;
int flameD11;
int checkDoor = 0;

//remote
#include <IRremote.hpp>
#define ir 13
bool status = true;

void setup() {
  //door
  Serial.begin(9600);
  servo.attach(10);
  servo.write(0);
  lcd.init();
  lcd.backlight();
  lcd.setCursor(3, 0);
  lcd.print("WELCOME TO");
  lcd.setCursor(0, 1);
  lcd.print("DOOR LOCK SYSTEM");
  delay(3000);
  lcd.clear();

  //flame sensor
  pinMode(pinA1, INPUT);
  pinMode(pinD11, INPUT);
  pinMode(buzz, OUTPUT);

  //remote
  IrReceiver.begin(ir);
}

void loop() {
  
  if (IrReceiver.decode()) {
    //Serial.println(IrReceiver.decodedIRData.decodedRawData, HEX); // Print the received IR data
    if (IrReceiver.decodedIRData.decodedRawData == 0xE916FF00) {
    	status = !status;
      digitalWrite(buzz, HIGH);
      delay(200);
      digitalWrite(buzz, LOW);
    }
    IrReceiver.resume(); 
  }

  if(status == true) {
    lcd.backlight();
    flameSensor();
    door();
  } else {
    lcd.noBacklight();
  }
}

void door() {
  lcd.setCursor(1, 0);
  lcd.print("ENTER PASSWORD");
  char key = keypad.getKey();
  if (key != NO_KEY) {
    delay(60);
    if (key == 'C') {
      resetPassword();
    } else if (key == 'D') {
      if (value == true) {
        doorLocked();
      } else if (value == false) {
        doorOpen();
      }
    } else {
      processNumberKey(key);
    }
  }
}

void processNumberKey(char key) {
  lcd.setCursor(a, 1);
  lcd.print("*");
  a++;
  if (a == 11) {
    a = 5;
  }
  currentPasswordLength++;
  password.append(key);
  if (currentPasswordLength == maxPasswordLength) {
    doorLocked();
    doorOpen();
  }
}

void doorOpen() {
if (password.evaluate()) {
    servo.write(0);
    delay(100);
    lcd.setCursor(0, 0);
    lcd.print("CORRECT PASSWORD");
    lcd.setCursor(0, 1);
    lcd.print("DOOR OPENED");
    delay(2000);
    lcd.clear();
    a = 5;
    value = true;
  } else {
    lcd.setCursor(0, 0);
    lcd.print("WRONG PASSWORD!");
    lcd.setCursor(0, 1);
    lcd.print("PLEASE TRY AGAIN");
    delay(2000);
    lcd.clear();
    a = 5;
  }
  resetPassword();
}

void resetPassword() {
  password.reset();
  currentPasswordLength = 0;
  lcd.clear();
  a = 5;
}

void doorLocked() {
  if (password.evaluate()) {
    servo.write(180);
    delay(100);
    lcd.setCursor(0, 0);
    lcd.print("CORRECT PASSWORD");
  lcd.setCursor(2, 1);
    lcd.print("DOOR LOCKED");
    delay(2000);
    lcd.clear();
    a = 5;
    value = false;
  } else {
    lcd.setCursor(0, 0);
    lcd.print("WRONG PASSWORD!");
    lcd.setCursor(0, 1);
    lcd.print("PLEASE TRY AGAIN");
    delay(2000);
    lcd.clear();
    a = 5;
  }
  resetPassword();
}

void flameSensor() {
  flameA1 = analogRead(pinA1);
  flameD11 =