Arduino/C3/Robot-Control-using-Bluetooth/English

From Script | Spoken-Tutorial
Revision as of 16:26, 29 September 2020 by Nirmala Venkat (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
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:
  • Bluetooth Communication
  • HC-05 Bluetooth Module and
  • Controlling a Robot using an Android application
Slide 3:

Pre-Requisites

To follow this tutorial, you should have a basic knowledge of:
  • Electronics and
  • C or C++ programming language
Slide 4:

System Requirements

To record this tutorial, I am using:
  • Ubuntu Linux 16.04 OS
  • Arduino UNO board
  • Arduino IDE and
  • Android Phone
Slide 5:

External Components

We require few external components:
  • HC-05 Bluetooth Module
  • L293D IC

We have learnt about the L293D Motor Driver IC in the earlier tutorial.

  • 9V Battery with Connector
  • 9Volts-1Ampere Adapter
Slide 6:

Bluetooth Communication

* Bluetooth communication is a wireless technology.
  • It is used to transfer data between different electronic devices.
  • It supports data, audio transmission with a range of 7 to 8 meters.
  • It is specially designed for short range wireless data communication.
Slide 7: * In this tutorial we will use the HC-05 Bluetooth module.
  • This module has two operating modes, namely Data Mode and AT Command Mode.
  • In Data Mode, it can send and receive data from other Bluetooth devices.
  • We will be using the Data Mode in our tutorial.
  • AT Command mode is used when you want to change the setting of the bluetooth module.
  • For example, to change the Baud Rate we can use AT Command Mode
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.
  • This is how I have done the setup of my Robot.
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.
  • Please download and extract them
  • Make a copy and then use them while practising
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:
  • Bluetooth Communication
  • HC-05 Bluetooth Module
  • Controlling a Robot using an Android application
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:
  • conducts workshops and
  • gives certificates.

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.

Contributors and Content Editors

Nancyvarkey, Nirmala Venkat