Introduction: How to Control an Arduino Car Via Bluetooth (for Beginners)

All we know that Arduino is an excellent prototyping platform, principally because it uses a friendly programming language and there are a lot of extra incredible components that provide us great experiences.
We can integrate the Arduino with differents shields or modules and build fantastic things. In this project i will show you how use the Bluetooth module to control a robot platform through commands coming from a smartphone.

Step 1: Parts

Hardware:

  1. Arduino Uno
  2. Motor Shield L293D Driver
  3. Bluetooth Module
  4. Robot platform

Software:

  1. Arduino IDE
  2. Bluetooth RC Controller (you can download this app here)

Step 2: Mount the Hardware

The mounting of the robotic platform is very easy. If you buy one like that, you will receive a manual with all steps.

To connect the electric circuit, you have to fit the shield on the Arduino and then connecting the motors to the shield. After that you have to connect the bluetooth module. The module pins depends on what you are using, but basically it has: VCC (connected to the 5V pin of the Arduino), GND (connected on GND on Arduino), RX (connected to the TX pin of the arduino) and TX (connected to the RX pin of the Arduino).

Step 3: Software

The code is also uncomplicated.

- To control the motors, i used the library <AFMotor.h>.

- The communication between the smartphone and the Bluetooth module was done using the serial communication arduino.

- The app "Bluetooth RC Controller" send to the bluetooth module the following commands:

  • Forward -> F
  • Back -> B
  • Left -> L
  • Right -> R
  • Forward Left -> G
  • Forward Right -> I
  • Back Left -> H
  • Back Right -> J
  • Stop -> S
  • Front Lights On -> W
  • Front Lights Off -> w
  • Back Lights On -> U
  • Back Lighst Off -> u
  • Horn On -> V
  • Horn Off -> v
  • Extra On -> X
  • Extra Off -> x
  • Speed 0 -> 0
  • Speed 10 -> 1
  • Speed 20 -> 2
  • Speed 30 -> 3
  • .
  • .
  • .
  • Speed 90 -> 9
  • Speed 100 -> q
  • Stop All -> D

In this project was used just the basic commands: Forward, Back, Left and Right.

The entire code is available for you to download.

Step 4: You Are Done

Now you have all you need to build your own robot controlled by a smartphone via Bluetooth. Easy and Funny.

THANK YOU

Comments

author
RIJULT (author)2017-06-08

I want to make a car on same basis but 4wd. Need help with code alteration

author
SamuelE13 (author)RIJULT2017-08-10

If you are making it steer like it already does you don't need to change the code just wire the same side wheels into the same outputs therefore giving them the same signal.

author
dbiswas6 (author)2017-06-24

hey i tried making it but it always say that the 'stop ()' function in the code is not defined! i tried all the solutions on the net but it still doesn't work. PLZ HELP!

author
abhi89ban (author)2017-06-17

i am using HC-05 does it change any thing in the procedure??...on checking the output on the serial monitor i am getting signs like "?" "*" etc...pls help me.

author
jupa1804 (author)2017-05-21

Hello guys! I have a problem with the project's supply. I've been using a 9V battery and circuit turns on and i can connect my device with the bluetooth, but a few seconds after the bluetooth turn off itself and disconnect from my device. I have a AC adapter which has a 12V and 2A output and works perfectly. But i really need a wireless supply. What can i do? Please help me!! .. Thanks to all.

author
hanzalap (author)jupa18042017-05-23

Same here

author
jupa1804 (author)hanzalap2017-06-02

Hey man, have resolved! Just put in serie two pair of battery AA, alkaline it's preffer and the connect it to the power of arduino.

author
hanzalap (author)2017-05-23

Hello guys! I have a problem with the project. I've been using a 9V battery and circuit and i can connect my device with the bluetooth,my car connects but it doesn't respond even if I use 4 AA batteries. What can i do? Please help me!! .. Thanks to all.

author
VitorP26 (author)2017-05-10

Help plz, i need the squem, how i connect the cables.

vitorpiovezam@yandex.com

IMG_20170510_191020.jpg
author
jupa1804 made it! (author)VitorP262017-05-21

You have to put the motor shield on the Arduino, be sure the pins match on the arduino ports, after to conect the bluetooth module you have to welding the cables form the module bluetooth to the motor shield's contacts, i hope the image could be helpful!

WP_20170521_11_07_18_Pro.jpgWP_20170521_11_07_41_Pro.jpgWP_20170521_11_07_48_Pro.jpg
author
supniz (author)2017-04-08

Hi, when I compile the sketch I get a lot of error messages. Could you please help me?

Arduino: 1.8.1 (Windows 7), Board: "Arduino/Genuino Uno"

C:\Users\user\Documents\Arduino\libraries\arduino_723047\src\Temboo.cpp: In member function 'int TembooChoreo::run(IPAddress, uint16_t, uint16_t)':

C:\Users\user\Documents\Arduino\libraries\arduino_723047\src\Temboo.cpp:281:52: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

if (!m_client.findUntil("HTTP/1.", HTTP_EOL)) {

^

C:\Users\user\Documents\Arduino\libraries\arduino_723047\src\Temboo.cpp:301:62: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

if (m_client.findUntil("x-temboo-time:", HTTP_EOH)) {

^

C:\Users\user\AppData\Local\Temp\cchwJani.ltrans0.ltrans.o: In function `__static_initialization_and_destruction_0':

C:\Users\user\Documents\Arduino\FOF4YFTIA0WX947/FOF4YFTIA0WX947.ino:7: undefined reference to `AF_DCMotor::AF_DCMotor(unsigned char, unsigned char)'

C:\Users\user\Documents\Arduino\FOF4YFTIA0WX947/FOF4YFTIA0WX947.ino:8: undefined reference to `AF_DCMotor::AF_DCMotor(unsigned char, unsigned char)'

C:\Users\user\AppData\Local\Temp\cchwJani.ltrans0.ltrans.o: In function `Stop':

C:\Users\user\Documents\Arduino\FOF4YFTIA0WX947/FOF4YFTIA0WX947.ino:74: undefined reference to `AF_DCMotor::setSpeed(unsigned char)'

C:\Users\user\Documents\Arduino\FOF4YFTIA0WX947/FOF4YFTIA0WX947.ino:75: undefined reference to `AF_DCMotor::run(unsigned char)'

C:\Users\user\Documents\Arduino\FOF4YFTIA0WX947/FOF4YFTIA0WX947.ino:76: undefined reference to `AF_DCMotor::setSpeed(unsigned char)'

C:\Users\user\Documents\Arduino\FOF4YFTIA0WX947/FOF4YFTIA0WX947.ino:77: undefined reference to `AF_DCMotor::run(unsigned char)'

C:\Users\user\AppData\Local\Temp\cchwJani.ltrans0.ltrans.o: In function `back':

C:\Users\user\Documents\Arduino\FOF4YFTIA0WX947/FOF4YFTIA0WX947.ino:50: undefined reference to `AF_DCMotor::setSpeed(unsigned char)'

C:\Users\user\Documents\Arduino\FOF4YFTIA0WX947/FOF4YFTIA0WX947.ino:51: undefined reference to `AF_DCMotor::run(unsigned char)'

C:\Users\user\Documents\Arduino\FOF4YFTIA0WX947/FOF4YFTIA0WX947.ino:52: undefined reference to `AF_DCMotor::setSpeed(unsigned char)'

C:\Users\user\AppData\Local\Temp\cchwJani.ltrans0.ltrans.o: In function `right':

C:\Users\user\Documents\Arduino\FOF4YFTIA0WX947/FOF4YFTIA0WX947.ino:66: undefined reference to `AF_DCMotor::setSpeed(unsigned char)'

C:\Users\user\AppData\Local\Temp\cchwJani.ltrans0.ltrans.o: In function `forward':

C:\Users\user\Documents\Arduino\FOF4YFTIA0WX947/FOF4YFTIA0WX947.ino:42: undefined reference to `AF_DCMotor::setSpeed(unsigned char)'

C:\Users\user\AppData\Local\Temp\cchwJani.ltrans0.ltrans.o: In function `left':

Multiple libraries were found for "AFMotor.h"

C:\Users\user\Documents\Arduino\FOF4YFTIA0WX947/FOF4YFTIA0WX947.ino:58: undefined reference to `AF_DCMotor::setSpeed(unsigned char)'

Used: C:\Users\user\Documents\Arduino\libraries\arduino_723047

Not used: C:\Users\user\Documents\Arduino\libraries\arduino_668460

Not used: C:\Users\user\Documents\Arduino\libraries\arduino_668460

C:\Users\user\Documents\Arduino\FOF4YFTIA0WX947/FOF4YFTIA0WX947.ino:59: undefined reference to `AF_DCMotor::run(unsigned char)'

Not used: C:\Users\user\Documents\Arduino\libraries\arduino_668460

Not used: C:\Users\user\Documents\Arduino\libraries\arduino_668460

C:\Users\user\Documents\Arduino\FOF4YFTIA0WX947/FOF4YFTIA0WX947.ino:60: undefined reference to `AF_DCMotor::setSpeed(unsigned char)'

C:\Users\user\AppData\Local\Temp\cchwJani.ltrans0.ltrans.o: In function `right':

C:\Users\user\Documents\Arduino\FOF4YFTIA0WX947/FOF4YFTIA0WX947.ino:67: undefined reference to `AF_DCMotor::run(unsigned char)'

C:\Users\user\Documents\Arduino\FOF4YFTIA0WX947/FOF4YFTIA0WX947.ino:68: undefined reference to `AF_DCMotor::setSpeed(unsigned char)'

C:\Users\user\Documents\Arduino\FOF4YFTIA0WX947/FOF4YFTIA0WX947.ino:69: undefined reference to `AF_DCMotor::run(unsigned char)'

collect2.exe: error: ld returned 1 exit status

exit status 1

Error compiling for board Arduino/Genuino Uno.

This report would have more information with

"Show verbose output during compilation"

option enabled in File -> Preferences.

author
CamaraJ1 (author)2017-04-04

I'm trying to add an LCD, HC-SR04 sensor powered by a servo motor, and LM35 temperature sensor to the robot but when I tried adding those codes to the existing code, only the LCD would run. Please advise. I am trying to get the car to work with these added things. I can attach the code if that helps.

author
Gautam thakkar (author)2017-03-30

How to I connect 4 geared dc motor with arduino bluetooth via and is it's arduino code for control it by bluetooth please send me pdf about it at my gmail gautamthakkar786@gmail.com please

author
Rodolfo BatacB (author)2017-03-29

what is the code if i use L298N motor driver?

author
Gautam thakkar (author)2017-03-29

sir you can send me circuit diagram at my gmail gautamthakkar786@gmail.com

author
Avinash2212420 (author)2017-03-25

It's not working.............errors are appeared " unable to rename ;core.a".............plz help me

author
Max AlejandroR (author)2017-03-23

sorry, but, my car only go to left and right, someone can help me? , and something interesting , when i connect to the computer its run all the forward backward left and right, but when i use batteries, four AA it run only left and right, Why?

author
CamaraJ1 (author)2017-02-01

Built the car as instructed but when we went to run it neither motors are running. Bluetooth module and Arduino lights are on and there are no errors in our code. Is this the complete code? Using the carBluetooth_V01.ino code. Please advise.

author
MananC3 (author)CamaraJ12017-02-03

#include <AFMotor.h>

AF_DCMotor motor2(2);

AF_DCMotor motor4(4);

char command;

void setup()

{

Serial.begin(9600);

}

void loop()

{

if(Serial.available() > 0)

{

command = Serial.read();

switch(command)

{

case 'F':motor2.run(FORWARD);

motor4.run(FORWARD);

break;

case 'B': motor2.run(BACKWARD);

motor4.run(BACKWARD);

break;

case 'L': motor2.run(BACKWARD);

motor4.run(FORWARD);

break;

case 'R': motor2.run(FORWARD);

motor4.run(BACKWARD);

break;

}

}

}

Hey man try this code. I had used motor2 and motor4. You just replace it with your motor number. This code worked well. I have not tried using the above code, I made mine one.

author
PranP1 (author)MananC32017-02-24

The app is connecting with the bluetooth module, but when I click any of the arrow keys (on the app) the motors do not move. Can anyone help?

author
MananC3 (author)PranP12017-02-26

Check whether you gave 2 different supplies for motor shield as well as aruino and installed the adafruit library. Also check the connection of bluetooth module with the arduino, i.e RX n TX of bluetooth module to TX n RX of arduino respectively.

author
PranP1 (author)MananC32017-02-26

The only thing that I have done wrong is the 2 power supplies, but when I tried that there was still no change. On top of that even through the serial monitor (COM 3), It still doesn't work. No matter what button I press the motors don't turn.

author
MananC3 (author)MananC32017-02-03

The "above code" refers to that of the author.

author
CamaraJ1 (author)MananC32017-02-21

Thank you. I renamed my motors and its working

author
StanB13 (author)2017-01-24

Hello,

I am wondering if someone could help me...

I build the RC Car according to this tutorial, and it 's working as expected except with one minor issue... the motor spin is not as fast as I hoped so... the car is very slow, maybe 1 full spin per 2 seconds.

I used the exact motors as it was used in this tutorial, the same motor driver L293D and Bluetooth module HC-05.

The motors support max 6V and 300mA to full capacity, and the L293D driver can provide 600mA per motor, so this is not the issue. The two motors are connected to motor1 and motor2 inputs of the driver. The arduino board is powered by an external battery via USB of 5V, 1A. The motor shield is powered directly from arduino (the jumper is included).

I used the same code and library as in this tutorial with little modifications made by me.

If someone encountered this issue, a little help is most welcome.

Thank you.

author
MananC3 (author)StanB132017-02-26

Instead of taking supply from arduino to the motor shield use a different power source for motor shield. This may solve your problem.

author
MichaelC736 (author)2016-09-21

I have same motor driver and bluetooth module and im using Arduino Uno R3 but dont see how i can connect wires from HC05 when the moteor shield is in situ as the shield takes up all the pins needed. How did you get around this is it just wire wrapped around the motor shield pins on TX RX and Ground and Voltage

author
akn1 (author)MichaelC7362017-02-25

same bro here also..

author
Raj wadia (author)MichaelC7362017-01-19

i faced same problem. but finally soldered then on L293D motor driver shield

author
homers12 (author)MichaelC7362017-01-11

Iam having the same issue it would be great to get a solution

author
akn1 (author)2017-02-25

circuit please

author
AbhishekB114 made it! (author)2017-02-07

not able to upload code in arduino. some error message is coming.

Screenshot 2017-02-07 20.25.50.png
author
akn1 (author)AbhishekB1142017-02-25

same error occurred for me.. but after adding the afmotor.h library the problem solved. search on google to get the zip file and place on somewhere u can easily find and in arduino ide select sketch option and select include library and select the zip file and ur done. and then compile the code.

author
MuhammadN173 made it! (author)2017-02-11

works perfectly, thanks.

P_20170211_214923.jpg
author
soumya samal (author)2017-01-05

how to control the speed

author
MananC3 (author)soumya samal2017-02-03

Add motor4.setSpeed(255); in void setup. 255 refers to the highest speed.

author
Craftguy1 (author)2017-02-03

could you send me the code pls

Armando.Adame15.5@gmail.com

author
jfox1212 (author)2017-01-31

can someone send me the code? jeremy.fox@principia.edu?

author
jfox1212 (author)2017-01-31

We are having trouble with this, can't get the software to work. Anyone willing to help?

author
Eric20136065 (author)2016-03-12

Very good tutorial.

i can perfectly control my shieldh without the BT via COM3.

but i cant control anything with the app. please help me

author
Raj wadia (author)Eric201360652017-01-19

have you connected the hc 05 module with your phone via bluetooth?

author
АлексейГ17 (author)2016-03-31

Hello. Can you elaborate how you connect the PX and TX pins Bluetootn? The photo is not visible as you have them soldered.

author

Hi. The motor control shield difficults the access to Arduino pins. So, i used thin wires to connect Tx, Rx and supply voltage pins of the Bluetooth module with the shield.

author

Could you make a few photos?

author

i soldered and applied hot glue in it to keep it secured

temp_651249517.jpg
author
jjayJay (author)caiomoraes2016-04-07

Hi. Thanks for the video. But just confused how to hook up the bluetooth module. Did you tie around the wires to the pin of the motor shield and then located the shield on the arduino? Having trouble with that..

Thanks!

author
anocas26 (author)jjayJay2016-09-05

He used jumper wires

author
shazf (author)2015-06-14

bro if we are addng a led for head lights how is it possible to contolr via bluetooth?

author
caiomoraes (author)shazf2015-06-24

In this case, you can use the following commands:


  • Front Lights On -> W
  • Front Lights Off -> w

Add these commands in "switch case", like that:

switch(command){

case 'W'

digitalWrite(led, HIGH);

break;

case 'w'

digitalWrite(led, LOW);

break;

}

author
Raj wadia (author)caiomoraes2017-01-19

where to connect LEDS on motor shield ?

About This Instructable

100,622views

272favorites

License:

More by caiomoraes:How to control an arduino car via Bluetooth (for beginners)
Add instructable to: