Introduction: Arduino 4WD Rover Bluetooth Controlled by Android Phone/tablet

Picture of Arduino 4WD Rover Bluetooth Controlled by Android Phone/tablet

Arduino 4WD bluetooth controlled rover

This is a simple 4WD rover i made with Arduino.
the rover is controlled with an android phone or tablet over bluetooth. With that app you can control speed (using Arduino's pwm) , run it with the accelerometer and many other things.

The Arduino sketch is fully commented and open source, also the communication protocol (developed by me) from the app to Arduino is explained in the sketch .

Knowing the protocol you can use the app to control other robots...

Step 1: What You Need...

Picture of What You Need...

In order to build your own Arduino 4wd rover you should buy all the needed parts from your preferred store.

Most of them can be bought on ebay or amazon or other online electronics/hobby stores.

I try put some links but they could be outdated and not working, in this case try search the part manually by name. Sorry for that.

Anyway it’s a very simple robot kit usually made by a chassis, four Dc (up to 12V) motors with gearmotor and four wheel.

The parts used are:

  • 1 pcs of chassis complete with 4 DC motors, usually called Arduino rover 4wd, for example these:

http://www.robotik.center/index.php?route=product/... from http://www.robotik.center/

http://www.robotshop.com/en/dagu-4wd-chassis.html

http://www.robotshop.com/en/whippersnapper-runt-ro...

http://www.robotshop.com/en/juniorrunt-rover-kit.h...

Also a search on Ebay with the '4WD chassis robot arduino' keywords will return a lot of results.

  • 1 pcs of Arduino uno R3 or Arduino Leonardo board.
  • 1 pcs of Bluetooth module HC-05 or HC-06 with adapter board (Updated! 2017 , October 10, now supports HC-05 module for whose of you that already have it)
  • 1 pcs L298 bridge dual motor controller board.

There are many different of these but the pinout is 99% the same for all.
Just connect wires to the right pins based on the board diagram. with this tutorial you can find the datasheet of the one I used (see next step).

  • 3 pcs 3.7V 1200mA (or more) Li-Ion rechargeable battery AA size or 11,1V 1200mA LiPo battery pack.
    if you use the AA size battery you can put them in a battery holder.
  • 1 pcs Jack plug for Arduino power plug.
  • 1 pcs 1Kohm resistor.

Step 2: The Schematic Diagram...

Picture of The Schematic Diagram...

This is the schematic diagram for wiring the rover, please follow it while assembling it in the next step...

The L298 pdf will help you in case you have a different board pinout.

The HC-05 and HC-06 bt modules have the same pinout.

Sometimes the HC-05 has 6 pins instead of 4, check pins name on the bottom of the module to be sure to use correct pins.

Step 3: Assembling the Rover…

Picture of Assembling the Rover…

Follow the numbered images and the short video for the assembling order (some things may differ depending on your chassis…).

  1. Start with the motors on the chassis and wheels (image 1).
  2. Mount the L298 motor controller board and wire motors to it.
    Also add 2 wires to power the board (image 2 and 3).
  3. A piece of flat cable will connect the board to Arduino, you need only 6 wires but I left some other free for future use (maybe lights or ultrasonic sensor…).
    Also wire the jack plug , pay attention to polarity, the central pin is positive (+11.1V from battery) (image 4).
  4. Place the battery holder (or the battery pack) in the front of the rover, fix it with a piece of double-sided tape. If you choose the AA size battery it’s simple to remove them individually for recharging.
    If you choose a battery pack then could be a good idea to put a connector between the battery pack and the rover (image 5).
  5. Place the top of the rover…the flat cable and the jack plug passes through the hole (image 6)

  6. Assemble the bluetooth module with the resistor using a piece of flat cable (usually provided with the module). Cut the RXD wire (not the pin!) and solder the resistor in series to the wire.
    Seal with a heat-shrinkable tube (image 7).

  7. Place the Arduino board and the module. Connect the flat cable as in the schematic.
    Fix the Bluetooth module with a (very) little piece of double-sided tape.
    Connect the power jack to Arduino (image 8).

Step 4: The Arduino Sketch...

Picture of The Arduino Sketch...

Connect only the Bluetooth module HC-05 or HC-06 to Arduino as in the schematic (remember the 1Kohm resistor! on RXD pin of the module).

Open the Arduino sketch, uncomment the correct #define for your bluetooth module and be sure to comment the other one, see image. Upload it to an Arduino uno R3 or Leonardo Board, let the USB cable connected so the board remains powered.

1) Open the serial monitor and set the communication speed to 115200 baud and the NL (New Line) terminator.

In the serial monitor write the string: ‘Echo on’ and click Send, you should see ‘Echo is on’, this will echoes the next commands to the screen. Now write the string: ‘Device’ and click Send, you should see ‘Connected to: ArduinoRover’

Now follow the steps below to test the bluetooth connection depending on the module you chose. Note: when you send AT commands to the bluetooth module be sure commands are uppercase!

2a) Test for HC-06 module

Don't power off Arduino (if you did it, restart from point 1, you need the Echo on) and send the string ‘AT’ , you should see ‘HC-06> OK’ after about one second, this mean your Bluetooth module is correctly connected and the baud rate match the one set in the sketch at line: BtSerial.begin(9600).
To change the Bluetooth module name send the string ‘AT+NAMEArduino’ (for example), you should see 'HC-06> OKsetname' in about a second.
Now try to find the Bluetooth module with your smartphone or tablet and pair with it, insert the pin, usually 1234 when asked for.

2b) Test for HC-05 module

This bluetooth module is a bit tricky, so follow exactly the instructions and see the image with the screenshot from the IDE.
Power off Arduino by removing the USB cable.
There is a little pushbutton on the HC-05, see images, keep it pressed while reconnect the USB cable to power on Arduino and until the red led on the module starts flashing slowly.
This is a special command mode to be sure to match the BtSerial.begin(38400) speed in the sketch.
Now open the serial monitor as per point 1, enter 'Echo on' and click Send, you should see 'Echo is on'.
Send the string 'AT' , you should see 'HC-05> OK'.
Send the string 'AT+ORGL' , the module will respond 'HC-05> OK' , this resets the module to factory default parameters.
Send the string 'AT+UART?' , you should see 'HC-05> +UART:38400,0,0' this is the default communication speed.
Send the string 'AT+PSWD?' , you should see 'HC-05> +PSWD1234' this is the default password 1234.
Send the string 'AT+NAME=HC-05_rover' (for example, just use your preferred name after the sign=), it should respond with 'HC-05> OK' .
Now power off Arduino by removing the USB cable and power on again after a few seconds.
Try to find the Bluetooth module with your smartphone or tablet and pair with it, insert the pin you got in serial monitor, 1234, when asked for.

3) Complete the project (see assembling the rover) if not already done.

Step 5: The Android App...

Picture of The Android App...

Now your Rover is ready to run!

You need the FREE android app IRacer & Arduino BT controller from the playstore here:

https://play.google.com/store/apps/details?id=com....

The app allow you to drive the rover with the four way joystick in portrait mode or with 2 joystick (multitouch) in landscape mode.

Open the menu (the gear button), choose settings and select the device Arduino Rover.

From the menu, choose connect and select your already paired bluetooth module name from the list to connect to.

In the settings menu there are a lot of options (backgrounds, speed limits ...) to play with, enjoy :)

Comments

AppsByDavideV made it! (author)2017-10-07

Hello everyone !
The Instructables has been updated to support HC-05 modules as many of you are asking for.

Arduino code was updated as well :-)

Enjoy!

EmilS32 (author)2017-07-19

bro please reply

AppsByDavideV (author)EmilS322017-07-21

Hi EmilS32,

it seems an error of the IDE, maybe a missing driver/bad installation.

Try install the IDE again. Your problem is not related to the project.

I suggest you to try search on the Arduino forum if the reinstallation of the IDE doesn't fix the problem.

EmilS32 (author)AppsByDavideV2017-07-21

I have done it successfully bro... But the controls from the app is reversed. Eg:If driven front it runs left

AppsByDavideV (author)EmilS322017-07-22

go to the settings menu of the app. there are 2 switches to change the direction of the sliders.

don't forget to click on IMade it! under the title above... thanks!

EmilS32 (author)2017-07-19

BRO it shows following errors

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

Sketch uses 8122 bytes (25%) of program storage space. Maximum is 32256 bytes.

Global variables use 543 bytes (26%) of dynamic memory, leaving 1505 bytes for local variables. Maximum is 2048 bytes.

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x76

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x76

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x76

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x76

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x76

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x76

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x76

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x76

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x76

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x76

Problem uploading to board. See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.

This report would have more information with

"Show verbose output during compilation"

option enabled in File -> Preferences.

EmilS32 (author)2017-07-08

These are the photos of the driver bro

AppsByDavideV made it! (author)EmilS322017-07-09

Ok, i'm not quite sure without having it on my hands, anyway...

Assuming Motor1 is channel A and Motor 2 is channel B and referring to pg5 of the datasheet you find in this INSTRUCTABLE, try to connect as for picture below. In case of problem you must compare your board with the one of the datasheet.

EmilS32 (author)2017-07-03

Bro sorry for late reply.. O havn't seen it...But I can't find the perfect datasheet for my driver as the ic used in the driver is l²98n but the in the driver it is printed as l298

AppsByDavideV (author)EmilS322017-07-03

Send me some detailed images of the board with the driver

EmilS32 (author)2017-06-30

I have L298N..Will it work? Please reply

AppsByDavideV (author)EmilS322017-06-30

Hi,

please provide a link or schematic of your L298N board/shield so i can try to help

Tdhankot (author)2017-06-13

See this errors

AppsByDavideV (author)Tdhankot2017-06-13

Hi, it compiles correctly for me using the windows version of the Arduino IDE V1.8.1 and arduino nano.

Don't know about ArduinoDroid.

Why don't you use the arduino ide instead?

Tdhankot (author)AppsByDavideV2017-06-13

Ok i will try

Tdhankot (author)2017-06-13

Program errors
Uses of undeclared identifier​ 'setmotor'
Uses of undeclared identifier ' getreceivedbytes'
Uses of undeclared identifier
'btserialprint'
Uses of undeclared identifier 'readusbuffer'
Uses of undeclared identifier 'usbechomode'
Uses of undeclared identifier 'serialprint'
Uses of undeclared identifier 'usbsendatmode'
How to solve this please tell me

Tdhankot (author)2017-06-09

Arduino nano will work on this project?

AppsByDavideV (author)Tdhankot2017-06-09

Yes , it is the same as Leonardo that i already test. Carefully check the pinout to match the schematic.

sorry, i'm wrong. it is the same as UNO so it will work anyway. Again, check carefully the pinout

RIJULT (author)2017-06-01

I got a L293d shield. Will it work?

AppsByDavideV (author)RIJULT2017-06-03

Hi Rijult,

sorry for the late reply.

I think it will work but you need to adjust code to match this shield. Carefully check/compare your shield's pinout with the one used in the project. Also (probably) you need only 1/2 of your shield for this project.

Bye

sanskar kakde (author)2017-05-26

PLEASE, do you have a video i have to see how it works brother.....

Click on show all items in this instructables to view the video or:

and

IsaacP37 (author)2017-04-25

If only the wheels on the right part are turning , what you think may be the problem?

AppsByDavideV (author)IsaacP372017-04-25

Hi Isaac,

assuming you didn't change the arduino code, the problem could be only in the L298 motors driver wirings or broken module (internally the L298 has 2 separate driver).

Refer to the datasheet attached to this instructable if you have a different module/pinout.

Let me know :)

IsaacP37 (author)AppsByDavideV2017-04-26

Well i know each driver works because they work alternatively, so the ENA and ENB have a jumper that joins two different connections which I removed, and only made a single connection on both, I don't know if I should leave the jumper and make that single connection. When I alternatively make a connection on the different pins for each EN only side works

AppsByDavideV (author)IsaacP372017-04-26

Do you have a datasheet of your L298 module? ok a link to it?

peppers (author)2017-04-20

Hi Davide, nice work...
What you used to do the app in android?

AppsByDavideV (author)peppers2017-04-20

Hi Peppers,

i'm using B4A development tool:

https://www.b4x.com/b4a.html

Bye

Nidulaw (author)2017-04-10

thank you very very much

very very much

without you i couldnt make it

AppsByDavideV (author)Nidulaw2017-04-10

Hi,

solved?

Does it work?

Nidulaw (author)AppsByDavideV2017-04-12

hi
yes it worked very well
sorry for the late reply

AppsByDavideV (author)Nidulaw2017-04-12

Perfect Nidulaw, enjoy :)

Nidulaw (author)2017-04-09

hi

can i use a L298 driver module except a dual motor driver

thanks

AppsByDavideV (author)Nidulaw2017-04-09

Hi Nidulaw,

i think yes but i'm not sure without seeing a schematic of your module.

Of course you must match connections from your L298 driver board and the board i used.

Let me know if you need help (in that case please provide a link to a schematic of your board).

Bye

Nidulaw (author)AppsByDavideV2017-04-10

THIS IS MY DRIVER

AppsByDavideV (author)Nidulaw2017-04-10

It seem very similar to the suggested one but can't help with photo... i need a schematic. Where did you bought it? There is something written on the pcb? Name... model.. ?

NikhilR57 (author)2017-03-19

Hi all other stuffs are ready but i have motor driver shield not this module so can you please tell what are the changes i have to made in the code

THANKS inadvance

AppsByDavideV (author)NikhilR572017-03-19

Hi,

you can find the datasheet of the motor driver i used on step 2 of this instructables.
you should adapt pinout of this motor driver to your motor driver.

I can't be more specific without seeing your motor shield specifications/model, so please post a link of your product or a datasheet/schematic in pdf format.

Bye.

Davide

AppsByDavideV (author)2016-10-31

New V2.10 Arduino code:
-Improved Bluetooth buffer
-Arduino can send messages to the app (requires latest version of the android app)

Enjoy :)

EstebanCV (author)2016-04-24

Hi AppsByDavideV, i was following your instructions and i have problems setting the BT connection up. The code was uploaded correctly but when i type AT on the serial monitor i do not get any response, just "You sent: AT". What can i do to fix this?

vnäñï (author)EstebanCV 2016-10-29

for hc-05 the default baude rate for communication is 9600 and to enter into AT mode the baude rate is 38400 try changing the baude rates. Btserial.begin(38400).

In hc-05 if we want to enter into AT mode we should enable pin 34. we can do that in two ways

If your Hc-05 has a small button then hold pressing the button, by pressing the button pin 34 is HIGH, now power on the module and leave the button, the module will enter into mini AT mode. In mini AT mode, only some commands work like AT+VERSION etc. However, you can press the button and send the command and leave the button. In this way, you can send all AT commands.

The other way to enter into AT mode is by enabling pin34 by connecting EN or Enable pin of your hc-05 to vcc that is 3.3v or if your module supports 5v. The new factory out modules support upto 5v.

AppsByDavideV (author)2016-04-24

Hi EstebanCV,

wich BT module did you use? Are the rxd and txd pins connected in the right place ? be sure they aren't exchanged togheter.

Also when sending AT commands the module must not be connected over bluetooth.

You can try to change the line:

BtSerial.bregin(9600).

with a different speed, maybe your module is set to another speed.

Last: can you post a detailed image of the bluetooth module you are using?

Bye

I have been trying change both lines of code:

Serial.begin(57600);

BtSerial.begin(9600); and nothing happens

The module just keeps on blinking rapidly.TThe module that i am using is the HC 05 GW 040 which works as slave as well as master but i have no answer.

vnäñï (author)EstebanCV 2016-10-29

Yeah, I too got the same problem. Change serial.begin also to 9600, then it works. i.e Serial.begin(9600)

AppsByDavideV made it! (author)EstebanCV 2016-05-04

Hi EstebanCV, as far as i know the HC-05 and HC-06 have different communication protocols. This could be the problem. The project was developed with an HC-06 and actually works. I'm sorry i haven't an HC-05 to test and adapt the sketch.

You can try change the BtSerial.begin(9600); up to 115200 bps one step at a time but i think it's not enought: perharps the module waits for some extra characters

Attached the serial monitor result for the project using the HC-06 and the android app connected to arduino. Also find the pdf that explain the differences from the HC bt modules...

Hope it helps :)

Bye

MR32 (author)2016-07-05

BtSerial.readBytes(BtBuffer,7);.....................error

AppsByDavideV (author)MR322016-07-05

Hi MR32,

i can't get errors using the correct Arduino (Uno or Leonardo) with either the ide 1.6.9 from arduino.cc and the ide 1.7.10 from Arduino.org.

Check the Arduino you are using is correct (must be Uno or Leonardo)

Greetings

habibulilalbaab (author)2016-05-19

What can i use this driver for motor and use accu 12v for battery??

I think yes. Just compare the pinout of this driver with the datashett of the one i used . The datasheet is in the step2 of this instructable.. The 12V battery is good too. Make sure it can source almost 1,2A otherwise the voltage will drop causing Arduino random resets... bye

About This Instructable

18,720views

46favorites

License:

Bio: I like to develop android apps and electronics devices that can be controlled by that apps. My first pc was a commodore VIC20 hacked to ... More »
More by AppsByDavideV:Rangefinder for Garage Parking With ArduinoAndroid personal Home ServerArduino 4WD Rover Bluetooth Controlled by Android Phone/tablet
Add instructable to: