The idea of this week to use Blutooth module to control two outputs. Used LEDS to give different statues and servo.
Software Materials: Electronic Tools
Tinkercad
Arduino IDE
LEDs
Servo motor : Open/Close
Resistor 220 ohms 5V adapter
Jumper wires
Cable for Arduino Uno
Breadboard
Arduino Uno
TinkerCad Project: Arduino, Bluetooth HC0-5, LEDs and servo motor
I have collected the necessary items from the electronic kits and added them to the workstation.
I arranged the items on the breadboard and linked each one to particular connectors on the Arduino.
The servo motor was linked to port 9 of the Arduino.
I included 3 modifications: the red LED was linked to port 10, the green to port 8, and the orange LED to port 9.
Here:
Bluetooth module HC-05 is the input.
Servo motor and LEDs are the outputs.
I started connecting the Arduino’s ground (GND) to the negative rail of the breadboard and did the same for the 5V pin by connecting it to the positive rail.
And Then, I connected the servo’s ground and power to the Arduino’s rails and plugged its signal wire into digital pin 10. Setting it up myself really helped me see how the Arduino powers and controls each part of the project.
Next, I connected the Bluetooth device's RX to Arduino, TX's Bluetooth to RX's Arduino, and Bluetooth's Vcc to the positive wire and ground to ground. Setting it up myself helped me understand how the Arduino receives data from Bluetooth to control the project.
Finally, I added LEDs to indicate the different states we are in.
The circuit Process
Step 1: Preparing the components needed, Here is the list of all the electronic components I will need.
Step 2: Connect the positive and negative wires from the Arduino to the breadboard to set up the power rails.
Step 3: Add the LEDs to indicate the different states we are in.
Step 4: Connect the servo motor’s positive and negative wires to the breadboard power rails, and attach its output pin to digital pin D11 on the Arduino
Step 5: Connect the Bluetooth device's RX to Arduino, TX's Bluetooth to RX's Arduino, and Bluetooth's Vcc to the positive wire and ground to ground
Step 6: Uploading the code into Arduino Uno
Final look
This Arduino code controls a servo motor and three LEDs (red, green, and orange) based on serial input. It includes the Servo library and defines pin 10 for the red LED, pin 8 for the green LED, and pin 9 for the servo.
In the setup() function, it initializes serial communication at 9600 baud, sets the LED pins as outputs, attaches the servo to pin 11.
The loop() function continuously checks for incoming serial data. If '1' is received, the red LED turns on, the green and orange LEDs turn off, and the servo increases to 80. If '2' is received, the green LED turns on, the red and orange LEDs turn off, and the servo increases to 80, and if '3' is received, the orange LED turns on, the red and green LEDs turn off, and the servo decreases to 80. The serial monitor provides real-time feedback on received commands and actions
For the first time, my Bluetooth device didn't turn on. I was shocked, so my friend suggested that I use his Bluetooth to see if there was something wrong with my Bluetooth. I found out that we must connect first to the main Bluetooth of the phone, and after in the application
At first, my LEDs didn’t work because I accidentally burned the red one by using it without a resistor. Then I ran into coding problems: the code was showing erros, the Bluetooth module wasn’t responding, and the serial monitor wasn’t working as planned. I got stuck, and went back watching again the mideweek and eoweek videos and asked my friend Ali to help me check my wiring and code. I had to stop and learn how to make Bluetooth control and the servo motor work at the same time
when i entered the data, the serial monitor displays many message and it doesn't work as planned
Solution
In the if statement condition, after data I have to write two equals so that Bluetooth understands it, not just one. The second problem was with writing the function Serial.read(). I wrote it incorrectly, not as Serial.read().
Learning to control electronic devices using Bluetooth for my final project.
Don't put the Arduino and the power source at the same time; the Arduino will burn. ⚠️
This week felt really special compared to the others. I worked on something I never imagined I could do. It reminded me of the robot cars like Tesla, drone controlled by mobile