Arduino/C3/Robot-Control-using-Bluetooth/English
Visual Cue | Narration |
Slide 1: | Welcome to the spoken tutorial on Robot Control using Bluetooth |
Slide 2:
Learning Objectives |
In this tutorial, we will learn about:
|
Slide 3:
Pre-Requisites |
To follow this tutorial, you should have a basic knowledge of:
|
Slide 4:
System Requirements |
To record this tutorial, I am using:
|
Slide 5:
External Components |
We require few external components:
We have learnt about the L293D Motor Driver IC in the earlier tutorial.
|
Slide 6:
Bluetooth Communication |
* Bluetooth communication is a wireless technology.
|
Slide 7: | * In this tutorial we will use the HC-05 Bluetooth module.
|
Slide 8: | This is the assembled Robot.
We have already installed an app called car Bluetooth RC on Android phone. This app will control the movement of the Robot. |
Now we will see how to control the Robot via Bluetooth.
Let us see the circuit connection in detail. Do the actual connection with your hardware as explained here. | |
Slide 9:
Circuit Connection |
Connect the Arduino board to your computer using Arduino USB cable.
The 5V pin of the Arduino is connected to the 5V pin of the HC-05 module. The ground pin of the Arduino is connected to the ground pin of the HC-05 module. The Rx pin of the Bluetooth module is connected to the Tx pin of Arduino. The Tx pin of the Bluetooth module is connected to the Rx pin of Arduino. Now, note the blinking of LED in the Bluetooth module. This indicates that your Bluetooth module is switched on. |
Slide 10:
Circuit Connection |
Next do the below connections as explained.
Pin 16 of L293D IC is connected to 5V of Arduino. Pins 4,5,12,13 of the L293D IC are connected to the ground terminal. |
Slide 11:
Circuit Connection |
* Pins 1,2,7 of L293D IC are connected to pins 6,3,5 of Arduino respectively.
Pins 9,10,15 of L293D IC are connected to pins 11,10,9 of Arduino respectively. |
Slide 12:
Circuit Connection |
* One DC motor is connected to pin 3 and 6 of L293D IC.
The other DC motor is connected to pin 11 and 14 of L293D IC. Note: You have to connect the DC motors of the assembled robot as shown in figure. Recall that we have soldered a red and black wire to the wire leads of the motors. |
Slide 13:
Circuit Connection |
We require a separate power source for running the DC motors.
We will use a 9V battery to power the DC motors as arduino gives only 5V output. Positive terminal of the 9V battery is connected to pin 8 of L293D IC. The negative terminal of the battery is connected to the ground pin of the Arduino. These are all the connections you must do to perform the tasks shown in this tutorial. |
Slide 14:
Live Setup of Robot |
* Now place the breadboard and Arduino setup on the chassis.
|
Switch to Arduino IDE | Now we will write the program in Arduino IDE for the working of the Robot. |
Slide:
Code Files: |
* The files used in this tutorial are available in the Code Files link on this tutorial page.
|
Open the Arduino IDE. | |
Highlight according to narration | Type the code as shown:
These are the variables assigned for the pins on the arduino connected to L293D IC. The variable serialA is used to store the input character received by Bluetooth. |
void setup() | Type the code as shown in the void setup function.
Serial.begin function is used to make the Arduino ready to serially exchange messages. The messages are exchanged at 9600 baud rate. We will use the function pinMode to configure the pins to OUTPUT mode. |
void loop()
{ if (Serial.available() > 0) { serialA = Serial.read();Serial.println(serialA); } switch (serialA) |
Now we will write the code for the void loop.
The void loop function will move the Robot in forward, backward, right and left directions. Bluetooth module checks for commands given from the Android app. |
These lines of code make the robot move in the forward direction.
These lines of code make the robot turn in the left direction. These lines of code make the robot turn in the right direction. These lines of code make the robot move in a backward direction. Our program is ready now. | |
Click on compile and upload button on the toolbar | Click on the compile button to verify your program.
After compiling, a pop-up window will open to save the current program. I will save it as Bluetooth_Robot. Click on the save button to save the program. |
Before uploading the program, you must remove the Rx and Tx wires connected to Arduino.
Now click on the upload button to upload the current program on Arduino. When you have successfully uploaded the program, reconnect the Rx and Tx wires to the Arduino. | |
Now, remove the arduino’s USB cable from your computer.
For demonstration purpose, I have connected a 9V-1A adapter to run the Robot. It is connected at the Arduino jack available here. You can use a power bank or a battery instead, to power the Arduino. | |
Next, we will use the app and test the working of the Robot.
Take the Android phone in which you have downloaded the Car Bluetooth RC app. | |
Let us configure the Bluetooth in your Android phone.
Go to the settings option on your phone. Open the Bluetooth section. Turn ON your phone’s Bluetooth. Search for nearby devices. You will find HC-05 as one of the options in the list. Click on the HC-05 option. It will ask for a password. The default password for this bluetooth module is 1234. Type the password. In some cases, the password of the bluetooth module will be 0000. Now, your mobile is connected to the HC-05 Bluetooth module. You can now observe a different blinking pattern of the LED in the Bluetooth module. Turn OFF your phone’s Bluetooth. | |
Now, open the Car Bluetooth RC app in your phone.
The app will prompt to turn ON your phone’s Bluetooth. Click on Allow to Continue. On the top left corner of your phone, click on the arrow. Find the HC-05 option and click on it. You can see a message as Connected-OK. It indicates that your phone is now connected to the HC-05 Bluetooth Module. Now, it is ready to control the Robot. | |
Let us observe the working of the Robot.
When I press the forward button in the app, we can see the Robot moves in the forward direction. When I press the backward button, the Robot moves in the backward direction. | |
To turn the Robot towards the right hand side, press the right button in the app.
The right side motor stops rotating and the left side motor continues to rotate. This way the Robot turns to the right side. | |
Likewise, the Robot will move to the left direction when you press the left button.
Thus, we can control the movement of the Robot using bluetooth communication. | |
This brings us to the end of this tutorial. Let us summarize. | |
Slide 15:
Summary |
In this tutorial, we learnt:
|
Slide 16:
About Spoken Tutorial project |
The video at the following link summarizes the Spoken Tutorial project.
Please download and watch it. |
Slide 17:
Spoken Tutorial workshops |
The Spoken Tutorial Project Team:
For more details, please write to us. |
Slide 18:
Forum for specific questions |
Please post your timed queries in this forum. |
Slide 19:
Acknowledgement |
The Spoken Tutorial project is funded by MHRD, Government of India. |
This tutorial has been contributed by FOSSEE and Spoken Tutorial Project, IIT Bombay.
And this is Saurabh signing off. Thanks for watching. |