Easy Bluetooth Enabled Door Lock With Arduino + Android

FeaturedContest Winner
Picture of Easy Bluetooth Enabled Door Lock With Arduino + Android
Thanks to everyone who supported this project and voted for it in the Arduino Challenge! I was awarded second prize and hope to participate in more Arduino contests in the near future.

This tutorial will explain a simple way to make a password protected bluetooth door lock using your Arduino, which can be unlocked by sending a four digit pin from your Android phone!  The hardware setup is quite simple,  and the programming side of it is a bit tricky, but should be no problem for any Arduino ameuture.

Remove these adsRemove these ads by Signing Up

Step 1: Parts Needed

Picture of Parts Needed
1. Arduino (I am using the Duemilanove)

2. Electric Door Strike

3. Bluetooth Module ($9.99)

4. Power Supply (Required voltage and amperage differs among different door strikes/locks)

5. TIP120 Transistor

6. 1N4001 Diode

7. Hookup Wire

8. Solderless Breadboard

9. An Android phone (optional, considering that there are lots of devices you could use to send serial data to our bluetooth modem including Iphones, computers, and other Bluetooth devices)

Step 2: About The Transistor

Picture of About The Transistor
We'll start by focusing on one of the main components of the circuit, the transistor. Our transistor will allow us to control a device that requires more current than our Arduino can supply, by sending the transistor different values. The type of transistor we are using (the TIP120) has a base, collector, and an emitter which are labeled here. We will send the signal from pin 9 on the Arduino to the base of the transistor, and depending on the value sent, current will increase or decrease.

Step 3: Assemble The Circuit

The diagram shows how the transistor is wired up in our circuit. As you can see, we have a diode pointed away from ground that is connected to the collector of the transistor as well as the ground of the lock itself. This diode will protect our electronics from any back voltage that might be created when our lock is turned off. At this point you could set pin 9 to high or low to control the lock.
imr326 days ago

QR code scan version of arduino door lock.

leizo281 month ago

does anyone knows any app for iphone to do that? thank you

tiongson2 months ago

where is the connections of the electric door strike ???????

hi collin...its a great project..How did you code arduino? What program you used and what code, can you please help me with that? and Could you please upload a circuit diagram ? thank you.
randersen64 months ago
How do you open the door during a power outage ?
varun131685 months ago
How did you code arduino? What program you used and what code, can you please help me with that?
code for bluetooth module*
Great project. Could you please upload a circuit diagram so I can clearly see how to connect everything? Or a few close ups of how it's all connected to the breadboard.
bioana16 months ago
Hello. I tried to make this project but I have a problem with phone, he did't find the module of Bluetooth. My phone is samsung GT-S5610 and the module of Bluetooth is BT_BOARD V1.2pro. I dont know what is the problem. Please help me.Thank you.
jmarcinkowski6 months ago
Great project! Would you be able to upload a circuit diagram so that I can clearly see how its all connected?
Geniusdude1 year ago
What if you wanted to leave the door normally locked, then when you send the serial data unlock, and then stay that way until you send the data/passcode again at which point it would unlock? I cannot seem to figure out how the code would be modified for the life of me.
It does seem that this only unlocks it, and then leaves it unlocked forever until the Arduino is reset.

Add this line:
digitalWrite(lock, HIGH);
just before the line

Then it should unlock for 5 seconds and then lock again.
omaryeye9 months ago
bro my project is door access system using Bluetooth and a biometric scanner do you know a way how can I connect this project to a biometric scanner
It should be pretty easy to attach a fingerprint scanner to this... something like There should be plenty of pins left over on the Arduino.
JoshHawley9 months ago
shouldnt the diode be across the coil in reverse? like this:

JoshHawley9 months ago
what brand/model of door strike is that? did you mount it in a wooden door?
ganeshmastan11 months ago
anyone has the idea on how to modify this project so that the door lock/ relay should be activated once the bluetooth connection is paired between the phone and the module. and when unpaired(out of range), the relay should deactivated.

the system should work without any commands need to be send(in the project above we must send 'ABCD' to activate the relay) from the phone.

hope you can help me by giving some solution. much appreciated your help..
hi collin! can i also have some clear copy of the wiring?
what module did you used?
Quantiera1 year ago

I am using Arduino UNO, in this case is there any difference on the command line and I am using Arduino 1.5.2 to upload the command. Please give me more detail on this project.
danica171 year ago
what are those grounds? ground of power supply?
dmendoza121 year ago
What is the difference if you set PIN 9 to LOW or HIGH?
tolstoyan1 year ago
hi i started to build your project but i am having trouble with the wiring of the circuit, can you please send me a clear connection of the schematic diagram because i am confused on how you power the arduino and how the 12v is connected. when i tried to use the instruction above the electric door strike is keep on unlock. i am a beginner so i hope you can understand. my name is Louie from the Philippines. i hope you will respond. thank you
drmpf1 year ago
Nice Instructable Collin

Can I suggest my pfodApp ( ) as an alternative Android App

Using pfodApp allows you to customize the mobile's display to present the user with a named button.

No Andriod programming is required, just a simple text message from the Arduino. has example code for a Garage Door opener which can be easily reused to drive the lock, by changing the "Garage Door" text in the Arduino code to "Front Door Lock"

Collin if you would like to contact me, we could talk about a non-english (UTF8) version of pfodApp.
stormdead1 year ago
I want to make this device but... i want a button activate the lock....

I'm using a 9v battery instead of a power supply

Is this ok?....:

int buttonPin = 2;
int ledPin = 13;
int lock = 9; //pin 9 on Arduino
int buttonState = 0;

void setup() {
pinMode(lock, OUTPUT);
pinMode(buttonPin, INPUT);
digitalWrite(lock, HIGH);
pinMode(ledPin, OUTPUT);

void loop(){
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {
digitalWrite(ledPin, HIGH);
digitalWrite(lock, LOW);
else {
digitalWrite(ledPin, LOW);
digitalWrite(lock, HIGH);
stormdead1 year ago
Hi!... Where is connected the GND of the Power SUpply?
rickharris1 year ago
As always with this type of project what happens when the power supply fails how do you get in/out e.g in the case of a fire?

The program should give an audible signal to show code received otherwise you get multiple presses as users have no feedback.

Likewise you could offer audible feedback that the lock is open.
What happens if the power fails whilst the lock is open, there isn't anyway to re-lock it unless the mechanism has a mechanical default of closed.

This is the type of door latch often used on apartment buildings - it defaults to locked, except when energized, and has an audible click when it opens. It also still allows use of the key / knob, as usual.
The diode is in the wrong place: connect the end with the band to Vcc, connect the other end to the other end of the lock.

Collin Amedee (author)  steveastrouk1 year ago
I don't completely understand what the diode would protect in the case i set it up the way you mentioned. I implemented the diode after learning my lesson by killing my first transistor. I later used the picture (as shown) from an online tutorial to set up the diode correctly. The way i have it set up seems to be correct. If you disagree please explain
The Diode has to be across the inductive load - motor or relay. As shown in yours, it isn't/

When the current flowing in an inductor is forced to stop, the voltage across its terminals can rise to many tens or even hundreds of volts. The diode ensures that the current has an alternative path to flow through, as the transistor is switched off. Now, the maximum voltage across the coil is around 1V.

You should use a decent rectifier diode like the 1N4007.

if you really wanna get fancy and make it grind right to a stop you can use a relay to start the motor and a resistor across the motor when the relay is un-energized and the motor powered when energized. that will make the diode unnecessary because instead the resistor will dissapate the power and as an added bonus it make it a super fast stop (or lock)
The diode is necessary to protect the electronics, whether you have a relay or not. The diode also gives a certain amount of dynamic braking itself.
here is what i was thinking to use the arudino to drive a motor or an inductive load
here is what i was thinking to use the arudino to drive a motor or an inductive load
1.) An arduino won't drive a relay directly.
2.) Forget the resistor - you can't do better for braking than a shortcircuit.
3.) You still need a diode on the load, to prevent radiated noise.

Braking is caused by the resistor. if you just make it a short circuit across the motor then all electrical energy the motor generates and already has dissapates through the motors inductive load and the friction of the motor. the resistor causes the power to dissapate faster.

Just an example equation ignoring friction: if there are five amps flowing in a motor that has a inductive load around 2 ohms. Then power would be I^2 * R which would be 25 square amps * 2 ohms which would be 50 watts.

If i re-do the equations with five amps and a 100 ohm resistor accross the terminals of the motor (technically it would be 100 resistive and 2 inductive which ends up about 100.0199) then it would be 25 square amps * 100 ohms of impedance which is 2500 watts.

Just a small example of how a braking resistor brakes. Is it always necessary? nope. Can it be helpful and make your motor stop a LOT quicker? Yup. In my example the motor will stop around 50 times faster.

by the way on the diode i thought you were meaning accross the motor and being triggered by the relay. You can see in my diagram that i still included the diode across the output to prevent my relay from hurting my 'duino.

Oh and by the way if you search a website like mouser for relays limited the search to 5v and 40 mA (the specs for my 'duino's output). I got around 73 results

and just to make it fit my example i limited it to 5 Amps on the contacts. I still had multiple results

....Just saying
Much wrongness in one place.

There is no such thing as "inductive resistance" There is only inductive reactance. Reactance is NON-dissipative. The dissipation mechanism is resistive losses in the motor winding.

Firstly, your maths. Taking your example.

"5 amps across 2 Ohms" = 10V. (supply volts, say)

Dissipation = 50W.


Motor voltage = 10 V (imposed by the supply) resistance = 100 Ohms, power dissipation = 100/100 = 1 Watt. Current is now 10/100 = 100mA.

Your math fails. ADDING external resistance REDUCES the load on the motor !!!

And, OK, Add an INFINITE resistor, which by your specious argument would be THE best possible load ! Leave the pins of the motor open ! Does it now stop FASTER than when its shorted ? Of course not.

If this is a Duo or Duemilenova, DON'T blow your arduino up by running at Absolute maximum rating - the recommended limit is 20mA, and the sum of all pin currents must be <100mA. This is at a maximum package
temperature of 25 C, so derate accordingly at temperatures above that.

....just saying.


I have a mega that is what i looked up. Also you're right i said inductive and it shouldnt have been

By your math i have a 10V motor, fine no problem. Still dissapates the 50W i said.

Below that you are not following what i said. What you are describing sounds like you are puttting the motor in parallel with the resistor? i dont know why you would want to do that. now if you were to put the resistor in series to limit the current or something like that it would make more sense.

what i am saying is that if you just open the terminals of the motor ( or short them with a resistor) all of the back EMF that is generated is only dissapated by the friction and internal coils in the motor. thats pretty much just coasting to a stop.

the resistor dissapates the power in the motor more quickly than the friction and the internal wiring would. The catch is that the resistor should only be accross the terminals when the motor is not being powered.

By the way the reason that the motor doesn't slow faster when you leave the pins open is because the resistance is too great, the power can't break through the air. To break through a dielectric (like air or plastic) you dont need amps, you need volts. In a motor there are lower voltages (as you pointed out 10 in my example) and much higher amperages. Rebuttal?
Mm. No. Your're wrong right off

By your math i have a 10V motor, fine no problem. Still dissapates the 50W i said.

Your motor draws 10V at 5A
. Its drawing 50W from the supply. Its resistance is NOT 2 Ohms. You actually don't know what its resistance is unless you measure it. For any decent motor R is usually pretty small.  Try it.

what i am saying is that if you just open the terminals of the motor ( or short them with a resistor) all of the back EMF that is generated is only dissapated by the friction and internal coils in the motor. thats pretty much just coasting to a stop.

This is where you are wrong, and musunderstand the nature of the beast. SHORTING the terminals is exactly how it slows down fastest. You continue to confuse things like "Back EMF" and current in the motor, and have clearly not understood Lenz's law.

Please draw in detail where you believe a resistor should be connected in braking, and also what value it should be.

The resistor or short is only switched in during braking. Energy dissipation in the shorted motor is by the motors own winding resistance, since it is no longer a motor, but a generator, and the only source of energy for that generator is its own rotational inertia.

Look, Think about what  happens if you apply the full motor voltage when the motor is at rest. The full voltage will appear across the armature resistance which will dissipate maximum power. As the motor torque accelerates the mechanical load, the motor speed, hence the back-emf, rises and the current, hence the power in the armature falls. Eventually, the back-emf is almost equal to the input voltage and the power dissipated by the armature reaches an idle level.

WHen running under load, I increases, as back emf decreases, and torque increases.

Now consider removing the input voltage and shorting the armature. The full back-emf  (its a generator now)appears across the armature which dissipates almost as much as it did when starting. Eventually, the motor torque slows the mechanical load and eventually the motor stops.

So the armature power dissipation follows approximately the same curve against time when starting or stopping. So if your motor can survive having the full motor voltage applied from rest, it can survive having it's armature shorted at full speed.

In other words, what's the fastest way to dissipate the spinning energy in a generator ?  Open circuit ? Load = infiinty, no energy is dissipated. Short circuit ? Power = V^2/r r= armature resistance, therefore Power is very very high. Or with an external load, R.  Power = V^2/ (R+r) which is ALWAYS less than V^2/R

I suggest, instead of being wrong, you actually try it on a real PMDC motor, preferably a decent sized one, where brush frictional resistance becomes insignificant, and with a bit of flywheel on it for excitement.  On a big motor, you can destroy it if you repeat short circuit braking, but one or two times it's OK.

Graph is of the relationship between speed and braking time for various external loads. 

Also, bear in mind I've been designing motor control systems for 25 years.
Copy of DC braking.jpg

Get More Out of Instructables

Already have an Account?


PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!