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.