HELLO THERE!!
How are you guys? As usual, I hope everyone is fine and in good mood always. This week, I would like to share with you guys a simple system I made through out the weekend, a simple bluetooth door lock. Without further wasting our time, let's get straight to requirements of the system.
HARDWARE:
1. ARDUINO UNO
From the code block shown:
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
b)Arduino Coding
The arduino code(including the comments) are shown below:
#include<Servo.h> // include server library
Servo ser; // create servo object to control a servo
int poser = 0; // initial position of server
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);
}
}
}
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 (http://halim930112.blogspot.my/2016/02/voice-to-arduino.html) from my instructables(i'll try putting this experiment to my instructables also) to control the door lock!! This means you can control your door lock by voice control!!
A demonstration video for this system is shown below:
Well, that's all from me for this week guys. I hope to see you guys next week. Till then, HAPPY TINKERING.
How are you guys? As usual, I hope everyone is fine and in good mood always. This week, I would like to share with you guys a simple system I made through out the weekend, a simple bluetooth door lock. Without further wasting our time, let's get straight to requirements of the system.
HARDWARE:
1. ARDUINO UNO
2. HC-06 BLUETOOTH MODULE
3.SERVO MOTOR
4.DOOR LATCH/DOOR LOCK( I used the door lock as shown in the image below)
5.THIN GAUGE WIRE/THIN STEEL WIRE/ KEYCHAIN RING
SOFTWARE:
1. ARDUINO IDE
2.MIT APP INVENTOR
CIRCUIT ASSEMBLY:
What I did first is to tie or attach the servo motor to the latch as shown in the image below
.
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 is shown below:
CODING THE ARDUINO:
I would like to divide this into two parts:
a)MIT app inventor
b)Arduino
a)MIT app inventor
I had used this online software to design and code the interface for my door lock project. By designing the interface, I can control the door lock by using my smart phone via bluetooth connection.
The Interface of the door lock controller |
The code block that is used to code the interface |
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
b)Arduino Coding
The arduino code(including the comments) are shown below:
#include<Servo.h> // include server library
Servo ser; // create servo object to control a servo
int poser = 0; // initial position of server
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);
}
}
}
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 (http://halim930112.blogspot.my/2016/02/voice-to-arduino.html) from my instructables(i'll try putting this experiment to my instructables also) to control the door lock!! This means you can control your door lock by voice control!!
A demonstration video for this system is shown below:
Comments
Post a Comment