Introduction: Bluetooth RC CAR (Arduino HM-10 + IPhone Controller) Mode 1
This is my 2nd RC CAR project which I developed it by Bluetooth module (HM-10) using iPhone (BitBlue App). Also, you can use any other Apps which supports BLE.
I used below references for developing this project:
Datasheet of HM-10 Module: https://github.com/yostane/arduino-at-09/blob/mast...
Thanks to Martyn Currey website http://www.martyncurrey.com/hm-10-bluetooth-4ble-m...
I removed the ultrasonic sensor which I used in my 1st project and I used Bluetooth module instead.
my 1st project: https://www.instructables.com/id/Upgraded-RC-Toy-C...
Actually, there are two types of the controller (joystick) which we can use, as 4 buttons controller and directional joystick (analog).
In this project, I will show you 4 buttons controller.
Step 1: List of Parts
We need below parts:
1- RC Toy Car (original board inside the car to be removed), without the remote control: 1 Piece
2- Arduino (UNO) : 1 Piece
3- Battery (9V high amper), we used the battery of Drone: 1 Piece
4- DC motor Driver: 1 Piece
5- AT-09 BLE Bluetooth 4.0 Uart Transceiver Module CC2541 Central Switching compatible (HM-10): 1 piece
6- Wires
7- Glue gun
Step 2: Wiring Parts
For wiring and connecting parts, I drew parts by fritzing. Also, I took some photos for better understanding.
Any question, please let me know.
Note for HM-10 module:
You can simply connect HM-10 TX pin to Arduino but for connecting HM-10 RX pin, you need a voltage divider which I used three 1K Ohm resistors.
Step 3: My Arduino Code (Defining Pins)
Firstly I developed the Arduino code to use simple Joystick with 4 buttons. So I will give this code at first but later I found that there is another Joystick (Analog) like PS2 joystick which controlling is much easier than 4 buttons one.
Defining pins:
#include <SoftwareSerial.h> SoftwareSerial BTserial(2, 3); // RX | TX // Connect the HM-10 TX to the Arduino RX on pin 2. // Connect the HM-10 RX to the Arduino TX on pin 3 through a voltage divider. // char t; //defines pins numbers for Motor A (Forward & Reverse) int pinA1 = 11; int pinA2 = 10; //defines pins numbers for Motor B (Steering) int pinB1 = 6; int pinB2 = 5;
Step 4: My Arduino Code (setup)
The next code is for setup part.
void setup() { BTserial.begin(9600); /* Initialize Motor A Pin Modes */ pinMode (pinA1, OUTPUT); pinMode (pinA2, OUTPUT); /* Initialize Motor B Pin Modes */ pinMode (pinB1, OUTPUT); pinMode (pinB2, OUTPUT); }
This is for initializing Motor A and B pins.
Step 5: My Arduino Code (Loop)
This part is for loop section.
void loop() { if (BTserial.available()) { t = BTserial.read(); } if (t == 'F'){ forward(150); } else if (t == 'B'){ reverse(150); } else if (t == 'L'){ left(); } else if (t == 'R'){ right(); } else if (t == 'A'){ stopcar(); } delay(100); } void forward(int s){ digitalWrite (pinA1, HIGH); digitalWrite (pinA2, LOW); analogWrite (pinA1, s); } void reverse(int b){ digitalWrite (pinA1, LOW); digitalWrite (pinA2, HIGH); analogWrite (pinA2, b); } void stopcar(){ digitalWrite (pinA1, LOW); digitalWrite (pinA2, LOW); } void right(){ analogWrite (pinB2, 200); delay(50); digitalWrite (pinB2, LOW); } void left(){ analogWrite (pinB1, 200); delay(50); digitalWrite (pinB1, LOW); }
I will define it later.
Step 6: Download Files
You can download my code as attached.
7 Comments
2 years ago
will this work with the HC06?
Question 2 years ago on Step 6
Hello,
1. Why do you pin RXD (HM-10) to D3 (Arduino) with a voltage divider and TXD (HM-10) to D2 (Arduino)?
2. Instead of RXD (HM-10) to TXD (Arduino)
and TXD (HM-10) to RXD (Arduino)?
I’ve used the second set-up with the HM-10 on 3,3V and the Dabble app for iOS.
I’ve tried two codes but the app is not responding, the engine is. I will have to try out your code also...
Thanks in advance
Bas
Question 2 years ago
hi sir. i have a question. how to add another features button in the bluetooth app? i already edit the code. but it seem that the RX pin in the bluetooth app interface not responding. its shows "?". the TX shows the character and its working. the only problem is the RX is not receive for the additional feature button.
2 years ago
could you explain more about using joystick
3 years ago
Hi do you have the code to move it around using joystick in the app instead of using drectional buttons?
4 years ago
Thanks for sharing your code - do you have any more photos from your build besides the video? Thanks!
Reply 4 years ago
I will take and send some photos for you today. If you have any question, you can ask me.