Skip to main content

Arduino IR Remote Door Lock System with Solenoid Lock & Wireless Remote

In this tutorial, you will learn how to build an infrared remote-controlled door lock system using Arduino. Instead of RFID cards or keypads, this version uses an IR remote transmitter to unlock a solenoid door lock wirelessly.

This project demonstrates an important real-world embedded system concept: wireless command decoding and actuator control.

By completing this project, you will learn how to:
  • Send IR signals using an Arduino-based remote
  • Decode IR signals using an IR receiver
  • Control a relay and solenoid door lock
  • Implement a simple wireless security system
This project is ideal for beginners interested in home automation and security systems.

Why Use IR for a Door Lock?

There are many ways to build electronic door locks such as RFID cards, keypads, Bluetooth, and WiFi. Infrared control offers a simple and low-cost alternative.

Advantages of IR door locks:
  • Very inexpensive components
  • Easy to program and debug
  • No internet required
  • Ideal for indoor security systems
  • Works even without smartphones or apps
Limitations:
  • Requires line-of-sight
  • Short operating range (typically 3-6 meters)
This project is perfect for learning wireless control fundamentals before moving to more advanced authentication methods.

Watch Project Overview

How the System Works

This project uses two Arduino boards:
  • Transmitter Unit (Remote) → Sends IR signal when a button is pressed
  • Receiver Unit (Door Lock Controller) → Receives signal and unlocks the door
System flow:

Push Button → IR Transmitter → IR Receiver → Arduino → Relay → Solenoid Lock

When the correct IR code is received, the Arduino activates a relay that powers the solenoid lock.

How the Toggle Lock Mechanism Works

Instead of unlocking only for a few seconds, this version uses a toggle system:
  • First press → Unlock door
  • Second press → Lock door
This is achieved using a variable that flips between 0 and 1.
This method improves usability and reduces mechanical wear.

Components Required

  • Arduino Uno (Receiver)
  • Arduino Nano (IR Remote)
  • IR Transmitter Module (KY-005)
  • IR Receiver Module (KY-022)
  • Push button
  • 220Ω Resistor
  • 5V Relay Module
  • 12V Solenoid Door Lock
  • 12V Power Adapter
  • Breadboards and Jumper wires

Understanding Infrared Communication

Infrared communication works by transmitting pulses at a carrier frequency of 38 kHz. These pulses are invisible to the human eye but can be detected by IR receiver modules.

In this project we use the NEC IR protocol, which sends a unique 32-bit code for each button press.

The IR receiver filters out ambient light and detects only signals at this frequency, which makes the system reliable indoors.
Each button press sends a unique HEX code, which acts like a digital password. The Arduino reads this code and decides whether to unlock the door.

Project Architecture

Transmitter (Remote Unit)

  • Push button pressed
  • Arduino sends IR signal using IR LED

Receiver (Door Lock Unit)

  • IR receiver detects signal
  • Arduino verifies the code
  • Relay powers the solenoid lock

Why We Use a Relay

The Arduino operates at low voltage (5V) and can supply only a small amount of current.
A solenoid lock requires 12V and high current, which Arduino cannot provide directly.
The relay acts as an electrically controlled switch:
  • Arduino controls the relay
  • Relay controls the high-power solenoid
This protects the Arduino from damage.

Wiring 

Receiver Circuit (Door Lock)

IR Receiver Connections (KY-022)

  • S - D11
  • (+) - 5V
  • (-) - GND

Relay Module Connections 

  • S - D6
  • (+) - 5V
  • (-) - GND

Solenoid Lock Connections

Relay acts as a switch for the 12V lock.

12V Adapter → Relay → Solenoid Lock

Safety Note: The relay isolates the Arduino from the high-current solenoid.

Transmitter Circuit (IR Remote)

IR Transmitter Module (KY-005)

  • S - D3
  • (+) - 5V
  • (-) - GND
According to the IRremote library, D3 must be used for transmitting.

Push Button Connection

  • One side - D2
  • Other side - GND
We use INPUT_PULLUP mode, so the button reads LOW when pressed.

Power Supply Design

This project uses two different power sources:
  • Arduino Boards - 5V
  • Relay Module - 5V
  • Solenoid Lock - 12V
All GND connections must be common. This is a very important concept in electronics called common ground reference. 

Step 01: Install IRremote Library

Open Arduino IDE:
Sketch → Include Library → Manage Libraries
Search and install: IRremote by Ken Shirriff

Step 02: Find your IR Code

Upload example:
File → Examples → IRremote → IRrecvDump
Open Serial Monitor and press the remote button.
Write down the HEX IR code displayed.

This code acts as your digital key.

Step 03: Receiver Program Logic

The receiver program must:
  1. Wait for IR signal
  2. Decode received code
  3. Compare with stored code
  4. Toggle relay state
Example logic:
If received code == stored code
    Toggle door lock
Else
    Ignore signal

We toggle using:
value = 1 - value

This flips between ON and OFF states.

Step 04: Transmitter Program Logic

The transmitter program must:
  1. Detect button press
  2. Send IR code using NEC protocol
  3. Wait 40ms before next transmission
IR sending function: sendNEC(IR_CODE, 32)

Testing the IR Transmitter

Infrared light is invisible, but your phone camera can detect it.
Open your camera and point it at the IR LED while pressing the button.
If you see purple light, the transmitter works.

Testing the Door Lock

  1. Power Arduino receiver
  2. Power 12V solenoid supply
  3. Press remote button
  4. Relay should click and unlock the door

Troubleshooting Guide

IR Receiver Not Detecting Signals

  • Check pin D11
  • Confirm correct IR library installed
  • Verify baud rate in Serial Monitor

Relay Not Activating

  • Check D6 connection
  • Ensure relay module has 5V power

Solenoid Not Working

  • Verify 12V adapter
  • Confirm relay wiring

Safety Notes

  • Solenoid locks draw high current
  • Never power from Arduino 5V
  • Always use external 12V supply
  • Double-check wiring before powering

Conclusion

In this tutorial, you built a complete wireless door lock system using infrared communication and Arduino.

You learned how to:
  • Transmit and decode IR signals
  • Implement basic authentication logic
  • Interface relays with high-power devices
  • Build a practical home security project
This project demonstrates how simple wireless communication can be used to control real-world hardware. It also provides a strong foundation for more advanced smart security systems using RFID, Bluetooth, or IoT platforms.

FAQ

Why use two Arduinos?

One acts as the remote transmitter and the other as the door controller.

Can I use a TV remote instead?

Yes. Simply decode its IR code and replace it in the program.

Is IR secure?

IR works only in line-of-sight and short range. For higher security, consider RFID or Wi-Fi authentication.

Comments

Popular posts from this blog

Arduino Serial Communication Beginner Guide (UART Explained)

Serial communication is the backbone of most Arduino projects. It allows your Arduino to talk to your computer, Bluetooth modules, Wi-Fi modules, sensors, and even other Arduinos. If you have ever used the Serial Monitor, you have already used serial communication - now you will understand how it really works. By the end of this guide, you will learn: What serial communication is What UART means How Arduino communicates with devices How to send and receive data How baud rate works Common mistakes beginners make What is Serial Communication? Serial communication is a method of sending data one bit at a time over a single wire. Instead of sending many bits simultaneously (parallel communication), serial sends bits sequentially: Example: The letter A in binary = 01000001 These bits are sent one after another very quickly. This method is: Simple Reliable Perfect for microcontrollers What is UART? UART stands for: Universal Asynchronous Receiver Transmitter It is the hardware ins...

How to Connect HC-06 Bluetooth Module with Arduino (Step-by-Step Beginner Guide)

Bluetooth communication is one of the easiest ways to make Arduino projects wireless. Once you understand how to use a Bluetooth module, you can build robots, home automation systems, and smartphone-controlled devices. In this tutorial, you will learn how to interface the HC-06 Bluetooth module with Arduino and send data wirelessly using your phone.    By the end of this guide, you will be able to: Understand how the HC-06 Bluetooth module works Configure the module using AT commands Safely connect it to an Arduino Send and receive serial data over Bluetooth Build the foundation for wireless Arduino projects Watch the Project Overview What is the HC-06 Bluetooth Module? The HC-06 is a Bluetooth-to-Serial module designed to add wireless communication to microcontrollers such as Arduino. It uses Bluetooth 2.0 (SPP - Serial Port Protocol), which means it behaves like a wireless serial cable. Whatever is sent from the phone appears in Arduino’s Serial Monitor and vice versa. ...

How to Use SoftwareSerial on Arduino (Connect Multiple Serial Devices)

In the previous tutorial, you learned how Arduino uses hardware serial communication through pins 0 (RX) and 1 (TX). That built-in serial port is mainly used to communicate with your computer through the USB cable and Serial Monitor . But here is the problem beginners quickly face: Many popular modules use serial communication, such as: Bluetooth modules ( HC-05 / HC-06 ) GPS modules GSM modules Wi-Fi modules ( ESP8266 ) Arduino Uno has only one hardware serial port. So how can we connect these modules while still using the Serial Monitor? The solution is SoftwareSerial . In this tutorial you will learn how to create additional serial ports using normal digital pins. By the end, your Arduino will be able to talk to multiple serial devices. What is SoftwareSerial? SoftwareSerial is a special Arduino library that allows digital pins to behave like RX and TX pins. This means Arduino can create extra serial ports using software instead of hardware. Hardware Serial vs Software Seri...