Arduino 4WD Rover Bluetooth Controlled by Android
Arduino 4WD Rover Bluetooth Controlled by Android
by AppsByDavideV
Arduino 4WD bluetooth controlled rover source, also the communication protocol (developed
This is a simple 4WD rover i made with Arduino. by me) from the app to Arduino is explained in the
the rover is controlled with an android phone or tablet sketch .
over bluetooth. With that app you can control speed
(using Arduino's pwm) , run it with the accelerometer Knowing the protocol you can use the app to control
and many other things. other robots...
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.
1 pcs of chassis complete with 4 DC motors, usually called Arduino rover 4wd, for example these:
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.
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.
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.
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.
Download
https://www.instructables.com/ORIG/FCN/YABW/IHNTEND4/FCNYABWIHNTEND4.pdf
…
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).
3
1
1
2
https://www.youtube.com/watch?v=xmrNsbA97AE
Connect only the Bluetooth module HC-05 or HC-06 see 'HC-06> OKsetname' in about a second.
to Arduino as in the schematic (remember the 1Kohm Now try to find the Bluetooth module with your
resistor! on RXD pin of the module). smartphone or tablet and pair with it, insert the pin,
usually 1234 when asked for.
Open the Arduino sketch, uncomment the correct
#define for your bluetooth module and be sure to 2b) Test for HC-05 module
comment the other one, see image. Upload it to an
Arduino uno R3 or Leonardo Board, let the USB This bluetooth module is a bit tricky, so follow exactly
cable connected so the board remains powered. the instructions and see the image with the
screenshot from the IDE.
1) Open the serial monitor and set the communication Power off Arduino by removing the USB cable.
speed to 115200 baud and the NL (New Line) There is a little pushbutton on the HC-05, see
terminator. images, keep it pressed while reconnect the USB
cable to power on Arduino and until the red led on the
In the serial monitor write the string: ‘Echo on’ and module starts flashing slowly.
click Send, you should see ‘Echo is on’, this will This is a special command mode to be sure to match
echoes the next commands to the screen. Now write the BtSerial.begin(38400) speed in the sketch.
the string: ‘Device’ and click Send, you should see Now open the serial monitor as per point 1, enter
‘Connected to: ArduinoRover’ 'Echo on' and click Send, you should see 'Echo is on'.
Send the string 'AT' , you should see 'HC-05> OK'.
Now follow the steps below to test the bluetooth Send the string 'AT+ORGL' , the module will respond
connection depending on the module you chose. 'HC-05> OK' , this resets the module to factory
Note: when you send AT commands to the bluetooth default parameters.
module be sure commands are uppercase! Send the string 'AT+UART?' , you should see 'HC-
05> +UART:38400,0,0' this is the default
2a) Test for HC-06 module communication speed.
Send the string 'AT+PSWD?' , you should see 'HC-
Don't power off Arduino (if you did it, restart from 05> +PSWD1234' this is the default password 1234.
point 1, you need the Echo on) and send the string Send the string 'AT+NAME=HC-05_rover' (for
‘AT’ , you should see ‘HC-06> OK’ after about one example, just use your preferred name after the
second, this mean your Bluetooth module is correctly sign=), it should respond with 'HC-05> OK' .
connected and the baud rate match the one set in the Now power off Arduino by removing the USB cable
sketch at line: BtSerial.begin(9600). and power on again after a few seconds.
To change the Bluetooth module name send the Try to find the Bluetooth module with your
string ‘AT+NAMEArduino’ (for example), you should smartphone or tablet and pair with it, insert the pin
you got in serial monitor, 1234, when asked for. not already done.
Now your Rover is ready to run! Open the app menu (the 3 lines button),open the
app settings (the gear) -> Remote control setup ->
You need the FREE android app IRacer & Arduino click and select the device to drive: Arduino
BT controller from the playstore here: Rover.
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!
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.
I have done it successfully bro... But the controls from the app is reversed. Eg:If driven front it runs
left
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!
Hi,
please provide a link or schematic of your L298N board/shield so i can try to help
See this errors
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?
Ok i will try
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
Arduino nano will work on this project?
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
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
PLEASE, do you have a video i have to see how it works brother.....
//www.youtube.com/embed/xmrNsbA97AE
and
//www.youtube.com/embed/BGJLUEP8xfM
If only the wheels on the right part are turning , what you think may be the problem?
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 :)
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
Do you have a datasheet of your L298 module? ok a link to it?
hi
can i use a L298 driver module except a dual motor driver
thanks
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).
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.. ?
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
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
New V2.10 Arduino code:
-Improved Bluetooth buffer
-Arduino can send messages to the app (requires latest version of the android app)
Enjoy :)
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?
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.
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?
Yeah, I too got the same problem. Change serial.begin also to 9600, then it works. i.e
Serial.begin(9600)
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
BtSerial.readBytes(BtBuffer,7);.....................error
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