# Bluetooth Controlled Robotic car

I have just started with the youtube channel, so I decided to make a Bluetooth controlled robotic car. As am an electronics engineer I have knowledge about electronics. but I don't know how to build a custom android application. so Before making the project I learn about MIT app inventor and try to make one app which was a great success it is quite easy to do. In this article, we will learn how to make a custom Android application and how to configure the Bluetooth module with Arduino.
Hardware requirements:

• Arduino Uno
• Bluetooth HC-05
• l298n motor Driver
• acrylic sheet
• wheels x2
• geared dc motor x2
• 4.7k, 2.2k resistor
• jumper wires
• 12v battery
• 9v battery
• switch

Step 1:
Building Chassis
I used an acrylic sheet length of 18cm and width of 13cm. First, I positioned all parts that going to be mounted on the chassis. then I used a hot glue gun to stick the parts to acrylic you can use spacers or screws. after mounting all parts I stick the caster wheel at the bottom of the chassis.

Step 2:
Connection

Make the connection according to the circuit diagram. we can use separate power for Arduino. Motor driver and 12v battery connected through the switch. As we can see in the circuit diagram there is 2.2k and 4.7 k resistor connected to the pins of the bluetooth module. the main reason for this is the HC-05 Bluetooth module uses a logic level of 3.3v. While transmitting data from HC-05 to Arduino there is no problem because Arduino is capable of receiving data from 3.3v logic, but while receiving any data from Arduino to HC-05 Arduino uses 5v logic which may damage our Bluetooth module, to convert 5v logic level to 3.3v we use a voltage divider method. Make sure that there is common ground between motor driver and Arduino otherwise motor not work.

Step 3:
Programming

Code:
/*
Author:DIYelex
date: 3/8/2019
*/

#include <SoftwareSerial.h> // TX RX software library for bluetooth
SoftwareSerial mySerial(2, 3);  // Connect the TXD pin of BT module to pin 2 of the Arduino and the RXD pin of BT module to pin 3 of Arduino.
int Rightmotor1 = 4; //pin 1 of Rightmotor
int Rightmotor2 = 5; //pin2 of Rightmotor
int leftmotor1 = 6;//pin1 of leftmotor
int leftmotor2 = 7;//pin2 of leftmotor
int en1=9; //enable pin for Rightmotor
int en2=10; // enable pin for leftmotor
void setup()
{
pinMode(Rightmotor1,OUTPUT);  // attach Right Motor 1st wire to pin 4
pinMode(Rightmotor2,OUTPUT); // attach Right Motor 1st wire to pin 5
pinMode(leftmotor1,OUTPUT);// attach Right Motor 1st wire to pin 6
pinMode(leftmotor2,OUTPUT);// attach Right Motor 1st wire to pin 7
pinMode(en1,OUTPUT);  //attach motor drivers rightmotor enable pin to PWM pin 9 of arduino
pinMode(en2,OUTPUT);//attach motor drivers leftmotor enable pin to PWM pin 10 of arduino
Serial.begin(9600); //Setup usb serial connection to computer
mySerial.begin(9600);//Setup Bluetooth serial connection to android
}

void loop()
{
while(mySerial.available()){
delay(50);
char data = mySerial.read();//store the data come from bluetooth to char data
}

Serial.println(readString); ///Print the data to serial monitor which is given by bluetooth

digitalWrite(Rightmotor1, HIGH);  ////////////FORWARD ////////////////////////
digitalWrite(Rightmotor2, LOW);
digitalWrite(leftmotor1, HIGH);
digitalWrite(leftmotor2, LOW);
analogWrite(en1,200);// for controlling speed of Rightmotor vary the value from 0 to 255
analogWrite(en2,200);// for controlling speed of leftmotor vary the value from 0 to 255

}

digitalWrite(Rightmotor1, LOW);  ////////////BACK/////////////////////////////
digitalWrite(Rightmotor2, HIGH);
digitalWrite(leftmotor1, LOW);
digitalWrite(leftmotor2, HIGH);
analogWrite(en1,200);
analogWrite(en2,200);

}

digitalWrite(Rightmotor1, HIGH);/////////////LEFT////////////////////////////
digitalWrite(Rightmotor2, LOW);
digitalWrite(leftmotor1, LOW);
digitalWrite(leftmotor2, HIGH);
analogWrite(en1,80);
analogWrite(en2,80);

}

digitalWrite(Rightmotor1, LOW);/////////////RIGHT////////////////////////
digitalWrite(Rightmotor2, HIGH);
digitalWrite(leftmotor1, HIGH);
digitalWrite(leftmotor2, LOW);
analogWrite(en1,80);
analogWrite(en2,80);

}

digitalWrite(Rightmotor1, LOW); ///////////stop/////////////////
digitalWrite(Rightmotor2, LOW);
digitalWrite(leftmotor1, LOW);
digitalWrite(leftmotor2, LOW);

}

}
}
Step 4:
Android application

Now we have to build Bluetooth applications that would be capable of controlling your robot car. If you wish to download my application you can download it from github: The Bluetooth car

How I created this application was through App Inventor 2, The images above show both the "Designer" & "Block" view of my application so you can build and change thing up if you wish!

Steps for configuring bluetooth

• First turn on the switch of robot car
• Go to setting Click on the Bluetooth
• TabTurn Bluetooth on Wait for your phone to find the HC-05 Bluetooth module
• Once it has been found click it and input the password by default it should be either "1234" or "0000"
• Now open the application Bluetooth car Application and click the " Bluetooth image" button
• You should see the HC-05 Module (If not re-try the steps above) click on the Module
• The Application will then return automatically to the main screen and you can see the green text "connected"
• At this point, the HC-05 Modules Red LED should now be constantly on instead of pulsing meaning a device is currently connected.
Conclusion

watch this project video on youtube

Author
Diyelex
Views
481
Last update