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

125,609

277

171

Posted

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

5 People Made This Project!

Recommendations

  • Science of Cooking

    Science of Cooking
  • Spotless Contest

    Spotless Contest
  • Pocket-Sized Contest

    Pocket-Sized Contest
user

We have a be nice policy.
Please be positive and constructive.

Tips

please add diagram of connection of cables

2 Questions

i using the same things like you did, however my bluetooth module havent "blink" for should i said it not on. i connect the Vcc and GND the way it should be but the RX and TX are the one that i didnt understan. i using a arduino mega and its have 3 port of both RX and TX and i connected it at RX1 and TX1. still nothing happen. can you help me out ??

ok i just solve that, my mistake. but now the robot didnt move even its already be connected

Bro at the end of each code you entered the word "end", what will happen if u dont used "end" ? Will the mortors will keep on running

145 Comments

I'm getting these characters on the serial monitor when I press the arrows:
Y
þ
Y
Y
Y
Y
Does anyone know why?

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.

make sure to disconnect RX and TX pin when you compile, it is a common problem ;)

you need to install the library

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.

is it a new 9v battery? if it is nog it can be that it lost some of it's capacity and doesnt provide enough to run motors and drivers at the same time

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.

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