Introduction: Arduino+Bluetooth Control(hc-05)+Android

In this application, i want to learn how can work bluetooth module with arduino and appinventor for android. Maybe you can try to make a toy. I wish to explain each steps clearly..Let's start..

First we need to prepare this components.

1-RC car

2-Arduino UNO

3-HC-05 bluetooth module or similar

4-L293D Motor driver

5-Jumpers and cables

6-AA batteries x4

7-18250 battery x2

Step 1: Connect the Bluetooth Module

You can see the connections in the picture.

Step 2: Connect L293D Motor Driver

I made a PCB for my dc motors using L293D. You have to connect your L293D like this:

in4 = 13
in3 = 12
in2 = 11
in1 = 10
en2 = 9
en1 = 6

Dont forget to connect the power pins..

By the way there are two motors on RC car toy. First motor is for driving car, second motor is for steering axle .

Step 3: Code for Arduino Uno

int in4 = 13;
int in3 = 12;

int in2 = 11;

int in1 = 10;

int en2 = 9;

int en1 = 6;

void setup()

{

//for leonardo

/*Serial1.begin(9600);

while (!Serial) { ; // wait for serial port to connect. Needed for Leonardo only } */

Serial.begin(9600);

pinMode(in4, OUTPUT);

pinMode(in3, OUTPUT);

pinMode(in2, OUTPUT);

pinMode(in1, OUTPUT);

pinMode(en2, OUTPUT);

pinMode(en1, OUTPUT);

}

void loop() {

char karakter = Serial.read();

if (karakter == 'a')//forward

{

analogWrite(en1,160); // first motor for driving

analogWrite(en2,0); //second motor for steer axle

digitalWrite(in4,LOW);

digitalWrite(in3,HIGH);

}

if (karakter == 'b')//back

{

analogWrite(en1,160);

analogWrite(en2,0);

digitalWrite(in4,HIGH);

digitalWrite(in3,LOW);

}

if (karakter == 'c')//stop

{

analogWrite(en1,0);

analogWrite(en2,0);

}

if (karakter == 'd')//turn left

{

analogWrite(en2,255);

digitalWrite(in2,LOW);

digitalWrite(in1,HIGH);

}

if (karakter == 'e')//turn right

{

analogWrite(en2,255);

digitalWrite(in2,HIGH);

digitalWrite(in1,LOW);

}

}


Step 4: Android Part of the Project

I use appinventor 2 for android devices. First you need to register. this is the link for registration. http://ai2.appinventor.mit.edu/ After register, please login. You have to start a new project from the Projects menu.

There are 2 parts. Designer and blocks.( I upload the pictures)

After the coding, You can use an emulator or you can save your project .apk to your computer. I realized that i have to prepare a lesson video for this part. Sorry my english is not very well..If you save the .apk file please install on your android device..

Dont forget to fix your settings in your device. Allow app installs from 'unknown sources'

Settings--->Security---->Unknown sources