Arduino Systems: Simple Bluetooth Door Lock

by halim930112 in Circuits > Arduino

3029 Views, 13 Favorites, 0 Comments

Arduino Systems: Simple Bluetooth Door Lock

Arduino_Uno_-_R3.jpg

Hi guys, how are you? I hope everyone is fine and in good mood always. Sorry, I had not updated for a while. This is because I am posting my experiments on my own blog (http://halim930112.blogspot.my/). Feel free to visit and comment on the experiments. So, this week I would like to share with you guys a simple system I made through out the weekend, a simple bluetooth door lock. I can control the door lock by using my smartphone to open and close the door. Without further wasting our time, let's get straight to requirements of the system.

ITEMS USED

Arduino_Uno_-_R3.jpg
ServoMotor.jpg
HC-06.jpg
Hardware-Door-Lock-Barrel-Bolt-Latch-Padlock-Clasp-Set-Door-Chains-gate-door-lock-.jpg
il_340x270.366079556_9rfl.jpg

The Hardware used in the system are:

1. Arduino UNO

2. Servo Motor

3.HC-06 Bluetooth Module

4. Door Lock/Door Latch( I used the door lock as shown in the image)

5.Thin Gauge/ Steel Wire/ Keychain Ring

The Software that are used in the system are:

1. Arduino IDE

2. MIT app Inventor

ASSEMBLE THE CIRCUIT!!!

IMG_20160912_214103.jpg
BTMoToR.JPG

Circuits ASSEMBLE!!! Don't worry,assembling this circuit is easier than assembling the Avengers!! First of all, I tied/attach the servo motor to the door lock as shown in the image. After tying in the servo with the latch, the servo must be put in a suitable position( preferably in the middle of the latch) so that the open/close motion can be achieved properly. The connection of the servo with other peripherals of the circuit are also shown in the image.

SEE!!! I TOLD YOU ASSEMBLING THE CIRCUIT IS FASTER THAN ASSEMBLING THE AVENGERS!! :)

LET'S CODE EVERYBODY!!!

tinkerhutdoorlock.png
tinkerhutdoorlock1.png

For this part, I would like to divide it into two, MIT app Inventor and the Arduino Code. Let's see the MIT app Inventor interface and code blocks first. I had labelled the listpicker, buttons,labels and textboxes that are used in the interface. Now for the code block shown, here are some explanation regarding the blocks:

i) Listpicker is used to list out all the options ( in this case bluetooth connection). So, before picking, the listpicker will list out all available connections. After picking, the listpicker will set the bluetooth connection to the selected connection from the list

ii) When button is clicked, whatever in the test box will be sent to the other side of the bluetooth connection

OOOOOKK!!! After designing the interface, we must code the Arduino also. Don't worry, the Arduino code is as shown as below:

#include // include server library

Servo ser; // create servo object to control a servo

int poser = 0; // initial position of servo

String openup, closedown;//string variables
void setup()

{

Serial.begin(9600); // Serial comm begin at 9600bps

ser.attach(7);// server is connected at pin 7

openup = String("open");//string variable consists of the string shown

closedown = String("close");

}

void loop()

{

while(Serial.available()) //read while data is present

{

String value = Serial.readString(); //value read string from MIT

Serial.println(value);

if (value == openup)//if the string received is open

{

int pos =- 50;//position - 50

ser.write(pos);//servo will move accordingly

delay (15);

}

if (value == closedown)//if the string received is closed

{

int pos =+ 50;//position +50

ser.write(pos);//servo will move accordingly

delay (15);

}

}

}



CONCLUSION

Arduino Systems: Simple Bluetooth Door Lock

Upload the code to the Arduino and test it out!!. Connect your smartphone to the Arduino via bluetooth and start controlling the door lock!!You know what's cool? You can also use the Voice to Arduino code from my instructables to control the door lock!! This means you can control your door lock by voice control!! Check out the demo video also!!

Well, that's all from me for now. I hope to see you guys some other time. Till then, HAPPY TINKERING!!!