I needed this assignment idea to be related to the servo motor, so I can be more familiar with it since a big portion of my final project is based on it, upon a few searches, I found a very relatable application that may be applied to many applications in out daily life, and it is the car parking system using servo, buzzer and Bluetooth module.
Here is the link of inspiration: https://create.arduino.cc/projecthub/guruashishchoudhary29/automatic-parking-system-81d9fa
Tinkercad
Used to simulate electrical circuits and components, so you can calibrate your circuit calculations and needs before even going to the hardware steps.
Arduino IDE
Used to compile the code written in the programming sketches and upload it directly to our Arduino Board.
Arduino Bluetooth Control App
It is an android mobile app that is used to give inputs to arduino based on bluetooth module.
Tools and Materials
Arduino Uno Board
Ultrasonic Sensor
LDR Module
Servo Motor
LED
Breadboard
Jumpers and Wires
Input Components:
-Bluetooth module.
Output components:
- Servo motor.
- Buzzer.
So the bluetooth module has 6 pin, we will only need 4 of them, and they are VCC, GND, TXD and RXD
- VCC: Is connected to source power, and as the optimum power voltage for the bluetooth module is 3.3V, so it is connected to 3.3v pin in the arduino.
- GND: Is connected to ground.
- TXD: It is the transmitter in the bluetooth module, and it is connected to the RX in the arduino.
- RXD: It is the receiver in the bluetooth module, and it is connected to the TX in the arduino.
Note:
When uploading code to the arduino board, make sure to unplug the TX and RX pins from the arduino, as the arduino uses these pins in the uploading code process, so they have to be free.
So the first thing the code does is waiting for input data to be received from the bluetooth mobile application, if it doesn't it stays in a loop in this step until it does.
Then upon data receiving, starts to process actions based on it:
Input data = "1": The buzzer is powered on and the servo motor is turned off, or returns to its default position and then turns off.
Input data = "2": The servo motor is turned on with an angle of 90 degrees, as well as the buzzer is turned off.
Input data = "3": Both the servo motor and the buzzer is turned off and the servo motors return to its default angle.
If the input data i anything else, the code just neglects it and then repeat the loop again waiting for input.
The code consists of 9 parts, which will be explained in the following lines:
Part 1:
It is basically summoning all the libraries we will want to use in this program, in our case the servo motor library.
Part 2:
Defining all the instances of the hardware components we will use.
Part 3:
In this part we stored the pins numbers in meaningful variables so it can be easily used across the code without any problem, this is called decoupling.
Part 4:
Initiating the variables that will be used in the code. .
Part 5:
Initiating hardware components and setting the state for every used pin.
Part 6:
Creating a loop to handle the program while no data is coming, and how to handle if any data came.
Part 7:
The first condition - Powering the buzzer when having certain input.
Part 8:
The second condition - Powering the servo when having certain input.
Part 9:
The third condition - Powering off both the servo and the buzzer when having certain input.
The main function of the circuit is to act like a smart parking system that the user controls with his phone, so if the user is nearby and connected to the system's bluetooth module, he can open or close the parking door, as well as the door's siren for alerting purposes.
First thing I made connection between the arduino board and the bluetooth module, and made the connection between them and that data can be received and transmitted no problem.
Then after I finished the circuit diagram in Tinkercad, just prepared the components I used and fixed it in the breadboard, and after fixing all the components I started connecting them to the Arduino board.
Then I started programming and testing the functionality of each component apart, and when I get the handle of how the component works and how I want to use it, I merge it into my code, applying the OOP practices while working.
After validating the connections and the code are both working fine and as expected, then all the components where merged to have our final SMART GARAGE product prototype.
Was helping my peers in explaining and going through difficulties in the coding and programming part, as I have working experience in, summary to the topics was how to make the code modular while interacting with different action components, and how to get the proper data from the bluetooth module.
While coding the bluetooth module, in the beginning I wasn't getting any data to the serial monitor when inserting input data from the mobile application, so surfed the internet searching this topic, and I found out the reason, that the bluetooth input is considered string values even if they are numbers, so I modified it and it works fine.