Build A Bluetooth Controlled Car Using Android Phone

Introduction

In this lesson, you will learn how to control an Android-controlled car using Bluetooth.

Hardware requirements

  • The Arduino Uno
  • Bluetooth sensor
  • Motor driver
  • DC motor
  • Jumper wire
  • Chassis board

Steps to follow,

Step 1

Connect the Arduino board to the laptop(or)computer.

 

Step 2

Installation of Arduino software on the laptop.

 

Step 3

Open the Arduino software in a computer.

 

Step 4

You can see main page of the Arduino software.

 

Step 5

Then open a new page in the software.

select File→ New

 

New page will open in the software.

 

Step 6

Then Click TOOL→ Select BOARD → then press ARDUINO/GENUINO UNO R3

 

Set to the board Arduino Uno.

Step 7

Again Select TOOL → Select a PORT→ COM3 ARDUINO UNO

 

Port set the COM3

Step 8

I have given a source code that you can use or you can use own source code

Then select File → open → select written program →open the program

 

You have to select a code which is on this folder.

 

Select the program and open it.

 

Source code

I have given the program code.

  1. int motorLpin1 = 2;  
  2. int motorLpin2 = 3;  
  3. int motorRpin1 = 4;  
  4. int motorRpin2 = 5;  
  5. int motorLpwm = 10;  
  6. int motorRpwm = 11;  
  7. int motorSpeed = 125;  
  8. int turn = 45;  
  9. void setup() {  
  10.     Serial.begin(9600);  
  11.     Serial.flush();  
  12.     pinMode(motorLpin1, OUTPUT);  
  13.     pinMode(motorLpin2, OUTPUT);  
  14.     pinMode(motorRpin1, OUTPUT);  
  15.     pinMode(motorRpin2, OUTPUT);  
  16.     pinMode(motorLpwm, OUTPUT);  
  17.     pinMode(motorRpwm, OUTPUT);  
  18. }  
  19. void loop() {  
  20.     String input = "";  
  21.     while (Serial.available()) {  
  22.         input += (char) Serial.read();  
  23.         delay(5);  
  24.     }  
  25.     if (input == "n") {  
  26.         stp();  
  27.     } else if (input == "F") {  
  28.         fwd();  
  29.     } else if (input == "R") {  
  30.         rev();  
  31.     } else if (input.indexOf("TL") > -1) {  
  32.         lft();  
  33.     } else if (input.indexOf("TR") > -1) {  
  34.         rght();  
  35.     } else if (input != "") {  
  36.         motorSpeed = input.toInt();  
  37.     }  
  38. }  
  39. void fwd() {  
  40.     analogWrite(motorLpwm, motorSpeed);  
  41.     analogWrite(motorRpwm, motorSpeed);  
  42.     digitalWrite(motorLpin1, 1);  
  43.     digitalWrite(motorLpin2, 0);  
  44.     digitalWrite(motorRpin1, 1);  
  45.     digitalWrite(motorRpin2, 0);  
  46. }  
  47. void rev() {  
  48.     analogWrite(motorLpwm, motorSpeed);  
  49.     analogWrite(motorRpwm, motorSpeed);  
  50.     digitalWrite(motorLpin1, 0);  
  51.     digitalWrite(motorLpin2, 1);  
  52.     digitalWrite(motorRpin1, 0);  
  53.     digitalWrite(motorRpin2, 1);  
  54. }  
  55. void lft() {  
  56.     analogWrite(motorLpwm, motorSpeed – turn);  
  57.     analogWrite(motorRpwm, motorSpeed + turn);  
  58.     digitalWrite(motorLpin1, 0);  
  59.     digitalWrite(motorLpin2, 1);  
  60.     digitalWrite(motorRpin1, 1);  
  61.     digitalWrite(motorRpin2, 0);  
  62. }  
  63. void rght() {  
  64.     analogWrite(motorLpwm, motorSpeed + turn);  
  65.     analogWrite(motorRpwm, motorSpeed – turn);  
  66.     digitalWrite(motorLpin1, 1);  
  67.     digitalWrite(motorLpin2, 0);  
  68.     digitalWrite(motorRpin1, 0);  
  69.     digitalWrite(motorRpin2, 1);  
  70. }  
  71. void stp() {  
  72.     analogWrite(motorLpwm, 0);  
  73.     analogWrite(motorRpwm, 0);  
  74.     digitalWrite(motorLpin1, 1);  
  75.     digitalWrite(motorLpin2, 1);  
  76.     digitalWrite(motorRpin1, 1);  
  77.     digitalWrite(motorRpin2, 1);  
  78. }  

Step 9

Verify the program or compiler.

 

Step 10

Upload the code in the Arduino board.

 

Step 11

Then connect the hardware components as per the connection diagram given in the figure.

 

Complete the connection as per the diagram.

Step 12

Install the Bluetooth control robot application using the Playstore on your android phone.

 

Step 13

Open the Bluetooth control application on your phone.

 

Then select Bluetooth device in the application

 

Connect the HC05 Bluetooth module with the Android phone application.[password=1234 (or) 0000 ,from bluetooth module]

 

We can now operate the Arduino car using your android application.

Step 14

The Arduino car will be working successfully.

 

Move the Arduino car to the right, left, forward, back and side using the Android application.

Now you completely learned to control the Bluetooth Arduino car using your Android phone.

Summary

The Arduino project using an Android Bluetooth application to control the Arduino Uno car by connecting to the Aluetooth has been created and executed.

More exciting articles are coming up next.

Bir cevap yazın

E-posta hesabınız yayımlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir

This site uses Akismet to reduce spam. Learn how your comment data is processed.

TOP