Recently I rewatched the Amazing SpiderMan, in one scene Peter Parker locks and unlocks his door from his desk using a remote. When I saw this I instantly wanted my own for my door. After a bit of tinkering I got a working model. Heres how I made it
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Parts List
For this project we will need the following:
- Slide Lock (Get it here)
- Six screws for the slide lock
- Soldering Iron
- Glue Gun
- Drill Head
- Drill Head for pilot hole
- Box Cutter
- Computer with arduino IDE
Step 2: How It Works
The idea is that I can easily lock and unlock my door without having to carry a key or even go near it :D but this is only a fraction of what we can do. From here we could add a sensor like a knock sensor so we can unlock our door with a special knock or even a voice recognition system!
The servo arm will be connected to the slider lock and will move to 0 degrees to lock the door and 60 degrees to unlock it using commands it gets from out Bluetooth device.
Step 3: Wiring Diagram
Lets start by wiring the servo to the Arduino (I would like to note that even though i'm using the Arduino nano the Arduino uno will work just as well with the exact same pin layout)
- The Brown wire on the servo is ground and it gets connected to ground on the Arduino
- The Red wire is positive and it gets connect to 5v on the Arduino
- The Orange wire is the servos source connection and it gets connected to pin 9 on the Arduino
Now I would recommend testing the servo before moving on, you can do this by going to examples in the Arduino IDE and selecting sweep. When we are sure that the servo works we can add the bluetooth module. We will connect the rx pin on the bluetooth module to the tx pin on the Arduino and the tx pin on the bluetooth module to the rx pin on the Arduino But don't do this yet! while these connections are made nothing can be uploaded to the Arduino so make sure you upload the code before soldering.
With this in mind this is how we wire the bluetooth module to the Arduino
- Rx pin on the bluetooth module connects to the Tx pin on the Arduino
- Tx pin on the bluetooth module connects to the Rx pin on the Arduino
- Vcc (positive) on the bluetooth module connects the 3.3v on the Arduino
- Ground goes to Ground
If any of this was confusing please follow the wires on the picture provided
Step 4: Testing
Now that we have all the parts together lets make sure the servo is strong enough to push and pull the locking mechanism without a problem before I started designing the final concept I built a mock up just to make sure my servo was strong enough, at first mine wasn't so I added a tiny bit of oil on the sliding mechanism which helped everything move smoothly. Its really crucial that everything moves smoothly or there is a chance you'll get locked on or out of your room! :D
Step 5: Electronics Casing
I decided to leave my servo "exposed" and to only build a small cardboard case to protect the arduino nano and Bluetooth module. We can build this by tracing the around the arduino nano onto a peice of cardboard and add about 1 cm (0,39 inch) of space onto each side now we have to cut out the other 5 sides of the rectangular cube. We also have to cut a hole on one of the faces for the power cord to connect to the arduino.
The measurements for the case are:
- Bottom piece = 7.5cm by 4cm (2.95 by 1.57 inch)
- Top piece = 7.5cm by 4cm (2.95 by 1.57 inch)
- left piece = 7.5 cm by 4cm (2.95 by 1.57 inch)
- Right piece = 7.5 cm by 4cm (2.95 by 1.57 inch)
- Front face = 4cm by 4cm (1.57 by 1.57 inch) (cut power hole in this one)
- Back face = 4cm by 4cm (1.57 by 1.57 inch)
Step 6: The App
So to lock and unlock the door we need a device running either android or windows with bluetooth builtin, Mac users i wasnt able to get this working on an iphone or a macbook pro I think there might be some driver issues but im sure one of you can figure it out :D. If you're installing on Android you will need to go to the play store and download and app called Bluetooth Terminal and for windows its called TeraTerm next we need to connect the hc-05 to our phone it should be called linvor and the password will be either 0000 or 1234. Once its paired open the app we just installed, click on options and tap connect to device (insecure) now our phone is basically simulating the arduino serial monitor which means we can see and send information coming from the arduino.
If you type 0 and press enter you should see the door lock and see the message "door locked"
and when you type 1 and press enter you should see the door unlock and see the message "door unlocked"
The process is basically the exact same on windows except you need to download an application called Tera Term and you can find the download link here (https://ttssh2.osdn.jp/index.html.en)
Step 7: Mounting the Lock
First things first we need to mount the servo on the sliding lock we do this by cutting off the edge of the servo mounting holes so that when we lay the servo down it will be flush with the lock next we put the servo arm into the lock hole where the handle used to be and test that everything moves correctly if so glue it down.
Now we need to start drilling pilot holes in the door for the screws, place the sliding lock againts the door and use a pencil to trace where the holes are now drill the pilot holes where you made the traces drill them to the depth of about 2.5 cm now place the the lock againts the door and screw in the screws onces its secure make sure the system still works
Step 8: Power Supply
To make sure we can leave this we are going to need a power supply, the cable and usb mini plug to connect to the arduino.
Connect the ground connection on the power supply to the ground connection on the usb mini port and connect the red cable to the red cable on the usb mini port now lead the cable from the lock to one of the door hinges and from there lead it to a power outlet
Step 9: The Code
int pos = 0;
int state; int flag=0;
if(Serial.available() > 0)
state = Serial.read();
} // if the state is '0' the DC motor will turn off
if (state == '0')
else if (state == '1')
Step 10: Finished!
Enjoy your bluetooth controlled door lock, dont forget to mess with your friends by locking them out of your room!
Thanks for reading if you have any questions please feel free to pm me or leave the question in the comments.
Participated in the
Arduino Contest 2016