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

Picture of 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

Picture of 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

Picture of 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

Picture of 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

PranavJ23 (author)2017-11-12

the code is not compiling for arduino uno

Vedantjadhav (author)2017-10-30

Hii
I have made a car but i am unable to upload the code.
Help bro

sahasreddy (author)2017-10-26

hi!!.. 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?

Stonely0 (author)2017-08-26

Hi i had follow your built instruction and everything is working fine (thanks!). the control of my car with the app works great, except that my car stop after moving for about 100cm. then i let it rest for about 1 minute, and it can move again. same as turning and spinning. I am suspecting is my battery problem. i am powering my arduino board with a 9v Li-ion rechargeable and another 9v li-ion rechargeable for the adafruit motorshield v1. The power jumper on the motor shield is remove so that it only received power directly from 2nd power source and not from arduino board.

I am using 2 6v-9v motor with Tamiya Dual Gear Box. any idea why it stop and need to rest to continue? Thanks

RIJULT (author)2017-06-08

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

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.

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!

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.

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.

hanzalap (author)jupa18042017-05-23

Same here

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.

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.

VitorP26 (author)2017-05-10

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

vitorpiovezam@yandex.com

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!

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.

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.

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

Rodolfo BatacB (author)2017-03-29

what is the code if i use L298N motor driver?

Gautam thakkar (author)2017-03-29

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

Avinash2212420 (author)2017-03-25

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

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?

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.

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.

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?

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.

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.

MananC3 (author)MananC32017-02-03

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

CamaraJ1 (author)MananC32017-02-21

Thank you. I renamed my motors and its working

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.

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.

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

akn1 (author)MichaelC7362017-02-25

same bro here also..

Raj wadia (author)MichaelC7362017-01-19

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

homers12 (author)MichaelC7362017-01-11

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

akn1 (author)2017-02-25

circuit please

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

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

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.

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

works perfectly, thanks.

soumya samal (author)2017-01-05

how to control the speed

MananC3 (author)soumya samal2017-02-03

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

Craftguy1 (author)2017-02-03

could you send me the code pls

Armando.Adame15.5@gmail.com

jfox1212 (author)2017-01-31

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

jfox1212 (author)2017-01-31

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

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

Raj wadia (author)Eric201360652017-01-19

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

АлексейГ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.

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.

Could you make a few photos?

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

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!

About This Instructable

111,143views

276favorites

License:

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