Category: Main page » Microcontrollers

Simple RC car for beginners (Android control via Bluetooth)

This is a simple project of Android Bluetooth Car with Bluetooth control. This project is open source and multiplatform: Arduino (Processing), STM32, MSP430, PIC, AVR, FEZ Panda II (.NET Micro Framework) and may be even  Raspberry Pi.

To control the car used Android-device with a built-in accelerometer. Tilt forward - car goes forward, tilt to the left - car turns to the left, tilt back - car goes back. Speed of movement or rotation depends on how much you tilt the device. Sensitivity and value of the tilt set in the configuration Android-apps. Also are provided a normal way to control: the buttons on the screen. In addition to all I implemented the touch control. In version 1.2, I added a new type of control: like virtual steering wheel. Total 4 ways to control the RC Car.

Parts needed

1. Android device

The most important part - Android device with accelerometer and Bluetooth: tablet, smartphone and other... As an Android device, I used a cheap Chinese tablet "Ainol Aurora" with an external USB-Bluetooth module (because its not have own), connected via USB Host.

Ainol Aurora

2. DIY Car Chassis

We also need any chassis with 2 or 4 DC motors. You can use an old RC toy car. I bought a 4WD chassis with 4 motors on ebay. To control described in this project is most suitable track chassis.

Car Chassis

3. Controller (MCU)

As I said above, the project is planned to be multiplatform. At the present time I implemented the project for:
Arduino
STM32

Controllers

Controller must support 2 PWM and UART.

4. Bluetooth module

As a Bluetooth module uses cheap Chinese module HC-06, which has been described in this article.

Bluetooth Modules

5. Motor Driver

I used L298N Dual Bridge DC stepper Motor Driver module. It cost 4-5$ on eBay.

Motor Driver L298N

6. Other parts

Other parts

After assembly:

Other parts

Theory

All calculations are performed in the Android-application, and immediately calculate the values ​​of the PWM for the left and right motor. Application has flexible settings, such as the range of the PWM, the sensitivity of tilt, the minimum threshold for the PWM and other. Example commands transmitted by Bluetooth:
L-255\rR-120\r
L - the command to the left engine, R - for the right
A dash means the motor rotation to move back
255 - PWM value (for Arduino is the maximum speed of rotation)
\r - end of command.
On this command RC car will move forward and slightly rotated to the right, as right engine rotates slowly left.

L255\rR-255\r
On this command the left engine will rotate back and forward right, forcing a car to rotate around its axis counterclockwise.

H1\r
Command is an additional channel to which you can connect for example lights, sound, etc.

Symbols command L, R and H can be defined in the settings of Android-applications.

In the MCU control program provides a timer that shuts off the engine if the last command was received more than n-seconds ago. The data are stored in the EEPROM memory of the controller and can be changed from Android device. The range of this setting is from 0.1 seconds to 99.9 seconds. This setting can be disabled. To work with EEPROM provides commands: Fr - reading values ​​and Fw - record values.

Electronics

Block diagram of CxemCAR:

Ainol Aurora

As we can see, the controller (Arduino, STM32, and others it does not matter which one) connects to Bluetooth module and a motor driver with two or four connected motors.

Android Application

The application for Android was written in Eclipse IDE. All sources of the project and the project for Eclipse, you can download below. Android version on your device must be > 3.0.

The application contains several activity. Main activity is a home screen with buttons running different operating modes and settings:

Main activity

There are 3 control modes Bluetooth-car: from accelerometer, screen buttons and touch-control.

The project structure in Eclipse:

CxemCar settings

Android application settings

Screenshot of settings CxemCar Android application version 1.0:

CxemCar settings

MAC address

To establish a connection with the RC Car's Bluetooth module, you must set MAC-address in the application settings. But first, you must configure the pair the devices on Android-device: open Settings -> Bluetooth and click "Search for devices". When the phone finds our Bluetooth-module, click them and enter password for pairing (usually "1234")

To know Bluetooth module MAC-address possible from any application, such as Bluetooth Terminal. To do this, click "Connect a device - Secure" and in the resulting window, click the button "Scan for devices". Software will be scans the Bluetooth devices and displays them MAC-address.

MAC address

Obtained MAC-address needs to be set in the Android-application CxemCAR

Assembly

4WD

The platform I have chosen Pirate-4WD chassis from the manufacturer DFRobot (SKU: ROB0003). Here is its description and video on the assembly.

After the base was assembled chassis with motors, solder the wires to the motors

Assembly

For alignment of motors I made a spacer from plastic

Assembly

Then the wheels have been set

Assembly

The wires from the 4-motor connect to the motor driver board L298N

Then connect the LED to indicate Bluetooth status through a resistor 470 Ohm.

Assembly

To connect the Bluetooth module or make tipsy all necessary wiring, in addition to the LED is power, GND, TX and RX. See the datashit for your Bluetooth module

I used the module HC-06. Wiring diagram is as follows:

Connect Bluetooth

The assembled HC-06 module is as follows:

Bluetooth

Its placed in heat-shrink tube of large diameter.

To power the motor, I used the battery holder with five AA batteries, that is, motor supply voltage of 7.5 volts. You can use the LiPo batteries and other

Battery Holder

CxemCAR project for Arduino
CxemCAR project for STM32

Download project source for Eclipse
Download APK

Version 1.2: Added a new type of management: the virtual steering wheel. Fixed class Handler. Improvements in Bluetooth class.

Video of demonstration the virtual steering wheel mode (1.2 version and above):

The current version of Android application: 1.2 (15.02.2013)

Author: Koltykov A.V.

Mihec 2013-06-07 01:24:30
Hi!
I'd like to know if you have any trouble with connecting BT Dongle to your Tablet.
I bough chinese tablet without internla BT. When I connect external BT dongle, there's nothing happened. Should I install some kind of driver?
My Android version is 4.1.1
Thanks for help or hint.

[Reply] [Reply with quote]
↑ 0 ↓
Admin 2013-06-07 09:36:25
No, you don't need install any driver for external bluetooth dongle. Maybe you Android tablet don't support USB OTG?

[Reply] [Reply with quote]
↑ 0 ↓
Kim 2013-04-06 21:07:12
Sir I have a question .. about the command r255 .. is it really need to follow the command style ? or i can create my own style of sending and reading a command ? do i really need to use EEPROM?

Thank You  :))

[Reply] [Reply with quote]
↑ +2 ↓
Admin 2013-04-07 08:04:51
Yes, you can create your style command

[Reply] [Reply with quote]
↑ -1 ↓
Robert 2013-03-20 01:15:10
This is a really cool project and im building it as well, i was wondering if you could show me some pictures of the wiring between the arduino, the motor controller, and the batteries.
Many thanks,

[Reply] [Reply with quote]
↑ +7 ↓
Robert 2013-02-25 22:08:31
Hello, Good project !!!
Is there any way to change the languge to ensglish? withouth recompiling? I do not have skills on Android programming. Thank you?

[Reply] [Reply with quote]
↑ +9 ↓
Denis 2013-04-30 11:28:30
Hi from France !
I have the same need: it would be great to have the English version!

[Reply] [Reply with quote]
↑ 0 ↓
dotism 2013-02-22 21:17:27
This is simply wonderful, thank you so much for sharing it with us.

I am having one little issue I was hoping to find some help with... Everything is working beautifully except the 'Backward' button in the 'Button control' interface. I can move the car backwards in other interfaces, though in 'Button' mode it doesn't seem to be working.

(I have made some modifications to the Arduino code to suit my project, and I don't see anything obvious in the Android code.)

Would someone be able to help me?

Thank you so much!

[Reply] [Reply with quote]
↑ +4 ↓
Piotr 2013-02-11 00:55:16
Is it possible to add displaying at android app data received by bt serial from arduino? I need some telemetry data (e.x. motor current etc) and sending it back over bt is the simplest way.

[Reply] [Reply with quote]
↑ +8 ↓
Piotr 2013-02-11 00:52:39
3) Could you please add additional (LEFT/RIGHT) channel for example served by volume up/down buttons? I've Velleman KSR11 robot I'd like to build forklift but one "motor control" is missing

[Reply] [Reply with quote]
↑ +9 ↓
Piotr 2013-02-11 00:51:52
2) I think that could be a good idea to set default application language to English.


[Reply] [Reply with quote]
↑ +13 ↓
Cyk 2013-02-05 17:52:50
Really great project.
The apk seems to be compiled for Android 4.x
Could you please compile it also for 2.3 (in my case: 2.3.7)?
Many thanks

[Reply] [Reply with quote]
↑ +5 ↓
Admin 2013-02-06 09:01:58
No. It's work only > 3.1. You can remove some functions from source and compile it for work with Android 2.3. Full project for Eclipse you can download below

[Reply] [Reply with quote]
↑ +8 ↓

Pages: [1]

Leave a comment

Your name:
Your Email:

Comment:
Type the characters: *
captcha
Refresh