Introduction: CxemCAR 1 - Android Control RC Car Over Bluetooth
To control the machine using 4 different way:
- 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.
- On-Screen Buttons.
- Touch Control via virtual circle.
- Wheel Control - like virtual steering wheel.
Step 1: Assembly
FEZ Panda II board to the chassis 4WD stuck with 2-sided scotch tape:
Step 2: Parts
For this project you need Android device with accelerometer and Bluetooth: tablet, smartphone and other... As an Android device, I used a cheap Chinese Phone "Jiayu g2s" with Android 4.1 OS.
Also you need any .NET Micro Framework board, Chassis, Bluetooth module (i'm use HC-06) and L298N Dual Bridge DC stepper Motor Driver module
Step 3: Calculations and Block Diagram
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 - 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.
On this command the left engine will rotate back and forward right, forcing a car to rotate around its axis counterclockwise.
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.
Step 4: Android Application
The application for Android was written in Eclipse IDE. All sources of the project and the project for Eclipse, you can download from GitHub. 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
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.
Step 5: Assembly
I soldered a Bluetooth-module to the FEZ Panda 2 and led status light. For communication between Arduino and Bluetooth, read this article: Arduino and Bluetooth. Module HC-06 placed in heat-shrink tube 10mm. Bluetooth-state LED with current limiting resistor (calculator) were also placed in heat-shrink tube.
Power DC motors are from the 3xLi-Po battery 3.7V 1100 mAh. The controller is powered by a single 3.7V Li-Po battery (although the required 5V, but works fine on 3.7V). Power supply of Bluetooth module is taken from the FEZ board.
Step 6: Source Code
We have a be nice policy.
Please be positive and constructive.