Arduino Projects

Remote Controlled Door Lock using Arduino & Electronic Lock

IR Remote Controlled Door Lock Project Description:

 

Remote Controlled Door Lock- in this article, you will learn how to make a Remote Controlled Door Lock using Arduino Uno, Keyes IR Sensor, Electronic Lock “Solenoid E Lock”, 12v SPDT type Relay, and an IR remote. This is going to be a very detailed tutorial explaining everything, including how to interface the Keyes infrared Sensor with the Arduino Uno, how to find the IR remote key codes of any IR remote, and how to use a relay to control an Electronic Lock or E Lock.

The programming is done using the Arduino IDE. If you are new to the Arduino Uno programming then I highly recommend you should read my article on the Arduino IDE “Arduino IDE Tutorial, how to Write Your First Program, install libraries & fix errors”.

The Remote Controlled Door Lock project is an ideal project for beginners. To keep things simple I have used only two buttons to control the Electronic Lock. One button is used to open the door and the other button is used to close the door. This project can be easily modified, the same project can also be used to turn ON and turn OFF a 110/220Vac light Bulb, and the circuit remains the same. All you need is to disconnect the Electronic Lock and connect a Bulb with the Relay Module.

I have also used the same IR remote and IR Sensor to control the speed of a DC motor. You can read this article by clicking on the link given below.

Arduino IR Remote based Fan speed controlling, Library, circuit, & code.

Without any further delay let’s get started!!!


Amazon Purchase Links:

IR Remote and Sensor for Arduino

12v Adaptor:

Arduino Uno

Arduino Nano

12v Electronic Door Lock / Elock / Solenoid Lock:

Other Tools and Components:

Top Arduino Sensors:

Super Starter kit for Beginners

Digital Oscilloscopes

Variable Supply

Digital Multimeter

Soldering iron kits

PCB small portable drill machines

*Please Note: These are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!


Remote Controlled Door Lock Project:

As I said earlier this project is based on the Keyes IR Sensor, a remote controller, and Arduino Uno. Controlling a door wirelessly is a kind of project that every beginner loves to work on. Once you learn how to make a remote access door lock, then you can control anything wirelessly using any IR remote. Let’s first talk about the basic electronic components used in this project.

Note: Copying and pasting will never help you if you want to learn the designing then read this article completely.

Keyes IR Sensor & MP3 remote controller:

In the picture below you can see the Keyes IR Sensor and an MP3 player remote controller. As I said earlier you can use any IR remote. But I have this IR remote so I am going to use this one. But in the video, I have explained how to use other IR remotes.

Remote Controlled Door Lock

The Keyes IR Sensor is a three-terminal Sensor clearly labeled with G, R, and Y.

G = GND

R = +5v

Y = Signal

As you can see the IR Remote controller has a total of 21 push buttons. You can use any of these buttons to control the Door Lock. As per the requirement of this project, I am going to use the Red button and Blue buttons for closing and opening the door.

Before you can use any remote controller button to control the door lock first, you need to find the keycodes.

Keyes IR Sensor Interfacing with Arduino:

Remote Controlled Door Lock

The Keyes IR Sensor interfacing with the Arduino Uno or Mega is very simple. As you can see in the connection diagram above, the R pin of the Keyes IR Sensor is connected with the Arduino’s 5v, The Y pin of the IR Sensor which is the signal pin is connected with the Arduino’s pin number 11, and the G pin of the Keyes IR Sensor is connected with the Arduino’s ground.

After you are done with the connections, upload the following program into the Arduino Uno or Mega2560.


Find the Hex values of the IR Remote Controller Key codes:

Before, you start the programming, first of all, make sure that you download the IRremote library by clicking on the download button given below:

Download: IRremote

For the IR remote based projects, you need to include the IRremote.h header file.

#include <IRremote.h>

int RECV_PIN = 11;
the Y pin of the Keyes IR Sensor is connected with the Arduino’s pin number 11. 

IRrecv irrecv(RECV_PIN);
decode_results results;

void setup()
{
  Serial.begin(9600); // activates the serial communication while 9600 is the baud rate. 
  irrecv.enableIRIn(); // Start the receiver
}

void loop() {

the following instructions are used to print the value of the key on the serial monitor. 
  if (irrecv.decode(&results)) {
    Serial.println(results.value, HEX);
    irrecv.resume(); // Receive the next value
  }
  delay(100);
}


Program explanation:

#include <IRremote.h>

int RECV_PIN = 11;

IRrecv irrecv(RECV_PIN);

decode_results results;

void setup()

{

Serial.begin(9600);

irrecv.enableIRIn(); // Start the receiver

}

void loop() {

if (irrecv.decode(&results)) {

Serial.println(results.value, HEX);

irrecv.resume(); // Receive the next value

}

delay(100);

}

After you upload the above program into the Arduino Uno Board, the next step is to open the Serial monitor and start pressing the keys on the remote controller. Following are the key codes I found.

Remote buttons hex codes:

Power button = EF3B295B

Play button = 69C6FA7D

These codes can be different in your case, if you are using a different IR Remote controller. So, I will be using the above codes to control the Door Lock.


Remote Controlled Door Lock Circuit Diagram:

Remote Controlled Door Lock

This is the final and complete circuit diagram of the IR Remote controlled Door Lock project. The Keyes IR Sensor connection with the Arduino Uno remains the same. The electronic door lock one wire is connected with the +12 volts and the other wire of the electronic lock is connected with the normally open contact of the 12 volt SPDT relay. While the common leg of the relay is connected with the Ground. So, by turning ON and turn OFF this relay the E Lock can be controlled.

The SPDT relay has a coil, this coil when energized makes the magnet, one side of this relay coil is connected with the +12 volts and the other side of the relay coil is connected with the collector of the 2n2222 NPN transistor. The emitter of the 2n2222 NPN transistor is connected with the Ground while the base of the 2n2222 NPN transistor is connected with the Arduino or Mega2560 pin number1 13 through a 10k resistor. This transistor is a BJT “bipolar junction transistor” and that’s why we need a resistor at its base.


The selection of the transistor is entirely based on the relay coil current which is needed to energize the relay coil. You can find the resistance of the relay coil using a digital multiple, the voltage is already known which is 12v and then using the ohms law V = IR, you can find the current in milliamps. So, select any NPN transistor whose collector current is greater than the relay coil current. In my case, I selected 2n2222 NPN transistor, as its collector current is much higher than the relay coil current and this transistor is easily available and is very cheap. I recommend you should go for a 2n2222 NPN transistor. The 10k resistor and 2n2222 make the relay driver circuit which is used to control the relay.

IR Remote Controlled Door Lock Arduino Programming:

#include "IRremote.h"

/*-----( Declare Constants )-----*/
int receiver = 11; // pin 1 of IR receiver to Arduino digital pin 11

/*-----( Declare objects )-----*/
IRrecv irrecv(receiver);           // create instance of 'irrecv'
decode_results results;            // create instance of 'decode_results'
/*-----( Declare Variables )-----*/

int led = 13;
// relay is connected with the pin number 13 which is used to control the electronic lock. I named //it led, you can change the variable name as elock

void setup()   /*----( SETUP: RUNS ONCE )----*/
{
  Serial.begin(9600);
  Serial.println("IR Receiver Raw Data + Button Decode Test");
  irrecv.enableIRIn(); // Start the receiver
  pinMode(led, OUTPUT);
  digitalWrite(led, LOW);

}/*--(end setup )---*/


void loop()   /*----( LOOP: RUNS CONSTANTLY )----*/
{
  if (irrecv.decode(&results)) // have we received an IR signal?

  {
//    Serial.println(results.value, HEX);  UN Comment to see raw values
    translateIR(); 
    irrecv.resume(); // receive the next value
  }  
}/* --(end main loop )-- */

/*-----( Declare User-written Functions )-----*/
void translateIR() // takes action based on IR code received

// describing Car MP3 IR codes 

{

  switch(results.value)

  {

  case 0xEF3B295B:  
    Serial.println(" Power OFF            "); 
     digitalWrite(led, LOW);
     delay(1000);
    break;

  case 0x69C6FA7D:  
    Serial.println(" Power ON             "); 
       digitalWrite(led, HIGH);
       delay(1000);
    break;

  default: 
    Serial.println(" other button   ");

  }

  delay(500);

}


With this our project comes to an end, you can also call this project as the

Smart lock with remote access

Remote access door lock

Remote control front door lock

Remote control house door lock

Wireless remote door lock

Magnetic door lock with remote control

Remote control door lock

Electronic door lock with remote control

Remote control door lock system

Remote controlled locks for doors

Remote operated door lock

Remote control locker

Remote control for door locks

DIY remote door lock

Remote access control door lock

Above are some of the famous keywords searched around the world.

For the practical demonstration watch video given below. Sorry for the bad recording, I recorded this video a long time ago. Don’t forget to Subscribe to my website and YouTube channel.



Watch Video Tutorial:

Engr Fahad

My name is Shahzada Fahad and I am an Electrical Engineer. I have been doing Job in UAE as a site engineer in an Electrical Construction Company. Currently, I am running my own YouTube channel "Electronic Clinic", and managing this Website. My Hobbies are * Watching Movies * Music * Martial Arts * Photography * Travelling * Make Sketches and so on...

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button