Theme: - A smart door controlled by Bluetooth and distance
Many people forget their keys at home or lose them, which makes it difficult and sometimes unsafe to enter their houses. Also, some people with disabilities or heavy bags find it hard to unlock doors using traditional keys. There is a need for a smarter and more convenient way to open doors without physical effort or risk of losing keys.
A smart door controlled by Bluetooth and distance can solve this problem by unlocking automatically when the authorized person’s phone is within a certain range and locking again when the person moves away.
Programs
Fritzing app
Arduino IDE
Material Kits
Breadboard
Jumper wires
Bluetooth sensor
Arduino Uno
Buzzer
Servo motor
USB Electric Arduino cable
Crocodile wires
Writing components on fritzing.
1- I downloaded fritzing app.
2- I used the breadboard, Arduino, breadboard, buzzer and downloaded the other components like Bluetooth, servo motor then imports them to be able to use them.
2- I connected the Buzzer pin to pin 7.
Servo pins: -
Pin 9, GND - GND
Positive - 5 v
3- I connected the pins of Arduino to the Bluetooth sensor as: -
Ground - GND breadboard
Vcc - 5v on breadboard
Tx - Rx
Rx - Tx
The servo is connected to pin 9. When button 1 is pressed on the phone, the servo motor moves and the door opens. Pressing button 2 activates the buzzer to warn people that something is wrong, while pressing button 3 turns the buzzer off.
The servo motor opens/closes the door.
The buzzer signals alerts.
The Bluetooth module lets you control the system wirelessly with a phone
The Bluetooth module receives commands (like "1" for open, "2" for alarm, "3" for stop).
Arduino reads the command and executes an action:
If command = 1: Servo rotates to open the door.
If command = 4 : Servo rotates to close the door.
If command = 2: Buzzer turns ON (warning/alarm).
If command = 3: Buzzer turns OFF.
The servo returns to its initial position to close the door after a delay.
Fritzing wiring
Writing the code
Open new sketch then choose → Examples → servo → sweep.
Preset up
1- Copy the pre void set up and define the buzzer to pin 7 & Servo pin 9 & int command
2- Make a place to store commands from Bluetooth/Serial.
Void Setup
1- Start Serial Communication: - Serial. begin (9600);
we use it to send numbers like 1, 2, 3, 4 to control the servo and buzzer.
2- Attach the servo to pin 9. myservo.attach(9);
3- Prepare buzzer pin 7 as output. pinMode(buzzerPin, OUTPUT);
4- Set servo = 0 means closed, buzzer = low means off.
myservo.write(0);
digitalWrite(buzzerPin, LOW);
Void Loop
1- Download if condition and copy it in the code and edit as following
2- If yes, it will read it.
if (Serial.available() > 0) {
command = Serial.parseInt();
3- If the command is 1 → Open the door
The servo moves to 90°, which means the door is open.
4- If the command is 4 → Close the door
The servo moves back to 0°, which means the door is closed.
5- If the command is 2 → Turn buzzer ON
The buzzer starts making sound.
6- If the command is 3 → Turn buzzer OFF
The buzzer stops making sound.
Real Wiring
I did the same with real jumpers
1- Buzzer pin to pin 7.
2- Servo pins: -
Pin 9, GND - GND
Positive - 5 v
3- Bluetooth sensor as: -
Ground - GND breadboard
Vcc - 5v on breadboard
Tx - Rx
Rx - Tx
4- Open the Bluetooth app on the phone, connect it with MD 35 (Bluetooth) connect from inside the app again and start checking by pressing 1 to open the servo, 4 to close it.
4 buzzer on as alarm and 3 to be off.
Real wiring connections
Real wiring connections
Real wiring connections
Real wiring connections
Real wiring connections
Preset up
Void setup
Loop setup
My instructor and colleagues guided me in identifying what needed to be edited in the code, and their support was truly helpful. They also advised me to check the actual connections, and one of my colleagues even shared her phone so I could connect to the Bluetooth, as my iPhone did not support that type of connection.
Bluetooth is keep losing signal and can't let both of servo motor and buzzer work together.
Solution: Restarting the Bluetooth sensor initially resolved the issue, but it soon stopped working again. My instructor reviewed the code and discovered that I needed to change the command in the loop setup from 0 to 4, after which it worked perfectly.
Gaining more experience in coding and connecting sensors and buzzers with Arduino has strengthened my skills. I also learned to restart the Arduino and sensor when I get stuck and to verify the accuracy of the wiring using Avometer.
All of this will make completing the final project much easier.
I had a great time collaborating with my colleagues to build a Micro Robot Arm that can be controlled via Bluetooth to catch fish. It was truly an amazing experience
This week assignment is useful because my final solution involves connecting a fan to a temperature sensor to reduce high temperature and I might use multiple fans to improve heat reduction.