Solenoid Lock Interfacing With Arduino


Hey geeks, welcome back to Techatronic. In this article, we are going to discuss the interfacing of a Solenoid Lock with Arduino.

HTML Image as link

Do you want to know more about the Arduino UNO microcontroller board, if so you can click to read? We use a Relay module for turning the solenoid lock on and off.

Also, a Solenoid lock is just like a normal or manual lock. the difference is only the solenoid locks operate with the electricity.  so this can be used at many places just like fingerprint security door lock.

So. in this Arduino tutorial you will learn how to interface this thing with the controller so that you can use this electronic device with any of your projects.

So, here we are giving you every possible information which helps you to learn and make your project possible for yourself.

What is a Solenoid Lock

Basically, it is an Electromagnetic lock that works on the principle that a current-carrying coil produces a magnetic field near it.

if you don’t know more bout magnetism you can read it on our website.

Inside the Solenoid valve,

  • there is a coil of insulated copper wire which is wound in the shape of a hollow cylinder.
  • There is an armature inside the coil which moves freely.
  • When we pass the electric current to the coil it generates a magnetic field near it.
  • The movement of the armature depends on the magnetic field generated by the insulated copper coil.

A solenoid lock looks like this.

How Does it Work?

  • The solenoid lock is controlled by Arduino, it generates the signals so the lock turns on and off after the delay of a second.
  • The lock is not directly connected with the Arduino instead of it we use a relay module.
  • As the lock works with electricity so in case of power failure the lock can’t be opened or closed. You can use different sensors with it to make a high-security lock system.
  • The solenoid lock needs a 12-volts DC supply for its functioning so you have to provide it.
  • Unlike manual locks, a solenoid lock is more secure and you don’t need any key to open it as it works on electricity.

Components Required

  • Arduino UNO
  • Solenoid Lock
  • DC 12-v supply
  • USB cable for uploading the code
  • Jumper wires
  • Breadboard

Circuit Diagram for the Project

Connection Table

Arduino UNO5V Single Channel Relay Module
( +5V ) VCC
D12 PinIN1 Input
12V DC AdaptorSolenoid Lock5V Single Channel Relay Module
  Normally Open
Positive Common
 Positive TerminalNormally Closed
NegativeNegative Terminal 

You have to make the connections according to the circuit diagram given above.

  • Connect the 5-volts pin of the Arduino to the VCC pin of the Relay module.
  • Join the GND pin of the Arduino to the GND pin of the Relay module.
  • Attach the Relay IN pin of the Relay module with the digital-12 pin of the Arduino as shown above.
  • You have to connect the positive wire of the DC power supply to the other side of the Relay module and the negative wire to the solenoid lock as shown.
  • Connect the positive wire of the solenoid lock with the Relay module. Now upload the code to the Arduino.
  • Also you cam make project with solenoid pump

Code for the Project

NOTE: Please upload the code given below to the Arduino as it is.

  void setup()   
  pinMode(12,OUTPUT); // RELAY PIN   
  digitalWrite(12,HIGH); // Normally ON Only For Chanies Relay Module   
  void loop()    
  digitalWrite(12,LOW); // RELAY ON   
  digitalWrite(12,HIGH); // RELAY OFF   

We hope that you understand the project well. If you are facing any errors do tell us in the comments section below. Please view more Tutorials on Arduino and Raspberry Pi.

RFID Lock System With Servo Using Arduino

Password based door lock system using Arduino with Keypad

RFID Sliding Door Lock Using Arduino|rfid project

RFID Sliding Door Lock Using Arduino|rfid project

We have an E-book on Arduino which contains 10+ projects on Arduino with detailed circuit diagrams and codes. After completing the circuit please upload the given code.


Video sample

2 thoughts on “Solenoid Lock Interfacing With Arduino”

Leave a Comment