Arduino UNO Based Smart Door Lock with Flame Detection and IR Remote Control
View and Edit Project In Cirkit Designer
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
- Microcontroller board based on the ATmega328P
- It has 14 digital input/output pins, 6 analog inputs, a 16 MHz quartz crystal, a USB connection, a power jack, an ICSP header, and a reset button.
LCD Display 16x4 I2C
- An alphanumeric liquid crystal display with 16 characters per line and 4 lines.
- It uses the I2C communication protocol for interfacing with the Arduino.
Servo
- A rotary actuator or linear actuator that allows for precise control of angular or linear position, velocity, and acceleration.
- It is commonly used for radio-controlled devices, robotics, and as part of servo mechanisms.
Flame Sensor
- A sensor designed to detect the presence of fire or other infrared (IR) sources.
- Typically used in fire detection systems.
Piezo Buzzer
- An electronic device that produces a tone, buzz, or beep when provided with an electrical signal.
- Often used for alarms, timers, and confirmation of user input.
VS1838B IR Receiver
- An infrared receiver tuned to receive IR signals at 38 kHz.
- It is commonly used in remote control systems.
4X4 Membrane Matrix Keypad
- A 16-button keypad providing a simple interface for user input.
- The keys are arranged in a 4x4 matrix configuration.
Wiring Details
Arduino UNO
- D12: Connected to Piezo Buzzer (pin 1)
- GND: Common ground with Piezo Buzzer, VS1838B IR Receiver, LCD Display, Flame Sensor, and Servo
- 5V: Powers the VS1838B IR Receiver, LCD Display, Servo, and Flame Sensor
- A1: Reads analog input from Flame Sensor (A0)
- A4 (SDA): I2C data line connected to LCD Display (SDA)
- A5 (SCL): I2C clock line connected to LCD Display (SCL)
- D11: Reads digital input from Flame Sensor (D0)
- D10: Controls Servo (PWM)
- D9 - D2: Connected to the corresponding R1 - R4 and C1 - C4 pins of the 4X4 Membrane Matrix Keypad
LCD Display 16x4 I2C
- SCL: Connected to Arduino UNO (A5)
- SDA: Connected to Arduino UNO (A4)
- VCC: Powered by Arduino UNO (5V)
- GND: Common ground with Arduino UNO
Servo
- GND: Common ground with Arduino UNO
- VCC: Powered by Arduino UNO (5V)
- PWM: Controlled by Arduino UNO (D10)
Flame Sensor
- GND: Common ground with Arduino UNO
- VCC: Powered by Arduino UNO (5V)
- D0: Digital output connected to Arduino UNO (D11)
- A0: Analog output connected to Arduino UNO (A1)
Piezo Buzzer
- pin 1: Controlled by Arduino UNO (D12)
- pin 2: Common ground with Arduino UNO
VS1838B IR Receiver
- OUT: IR signal output connected to Arduino UNO (D13)
- GND: Common ground with Arduino UNO
- VCC: Powered by Arduino UNO (5V)
4X4 Membrane Matrix Keypad
- R1 - R4: Connected to Arduino UNO (D9 - D6)
- C1 - C4: Connected to Arduino UNO (D5 - D2)
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 =