Bluetooth IOS DIY RC Car

20,135

95

18

Hello everybody, today I will show you how I made a RC Car, that you can control via iOS. I know how hard it is to hook up a Bluetooth module to the iOS, so today I will show you how I did mine, and its actually quite simple.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Parts List:

To get started, we will need to get an assortment of parts, mostly ranging to a total of $10-$20
- Wires (For connection from arduino to motor driver)
- Arduino (I used an uno, but I'm sure other types will work)
- 6 AA battery pack or 1 9V battery pack
- 1 L298n motor driver
- 4 tires
- 4 DC Motors
- Chassis of your choice (Recommend acrylic)
- 1 HM-10 Bluetooth Module

Step 2: Connections (Arduino to Motor Driver)

We will start off with the connections, and get difficult part out of the way. On the arduino, there are pins called "DIGITAL PINS", we will use these to connect from the arduino to the motor driver. To start off, I recommend getting 6 different colored wires to connect. Once the wires are obtained, connect as follows.

- Digital Pin 11 on arduino goes to IND on motor driver
- Digital Pin 10 on arduino goes to INC on motor driver
- Digital Pin 9 on arduino goes to ENA on motor driver
- Digital Pin 8 on arduino goes to ENB on motor driver
- Digital Pin 6 on arduino goes to INB on motor driver
- Digital Pin 5 on arduino goes to INA on motor driver

For the power connections from the arduino to the motor driver
- Vin on arduino goes to VCC on motor driver
- GND on arduino goes to GND on motor driver

Step 3: Wheels and Motors

For the wheels and motors, I essentially made my own design for the chassis and cut it on acrylic to have perfect spots for the motors. But if you do not have access to that, I would personally just make a motor holder type of thing for the wheels. The wheels are classic RC wheels, with a slot to put in where the motors would run. Once the motors are hooked up to the bottom of the chassis in your preferable choice, just simply slide the wheels on the ends. Once everything is set up, insert the wires from the end of the motors into the motor slots on the motor driver. It may take some fiddling around and switching the wires around, but you will know when they are in correctly.

Step 4: Bluetooth

The Bluetooth is actually quite simple to connect. There will be 5 pins on the end of the Bluetooth module, the STATE and EN pin will not be essential for what we are doing. Simply again, get 4 wires, suggested different colors, and plug them into the RX, TX, GND, and VCC pins on the module.
Once the wires are on:
- Place the RX wire on the module into the TX slot on the arduino
- Place the TX wire on the module into the RX slot on the arduino
- Place the VCC wire on the module into the 5V slot on the arduino
- Place the GND wire on the module into one of the GND slots on the arduino

Step 5: Code

The code is quite simple, but again quite complex. There are many things you may change on the code to make it go faster or to change the output letters for the serial, but here is a good place to start out.

Download HERE: http://www.mediafire.com/download/4ymjpcpfjt5x6sz/Bluetooth_RC_Code_with_iOS.ino

Once downloaded, upload your code to the arduino.

Step 6: App

The app I used is a free app on iOS called BLE Joystick. The app works wonderfully with the code provided. Once on the app, just connect via Bluetooth on the top right of the screen.

Step 7: Finish

To start up your car, just plug in the battery pack into your arduino. Keep all of your components on the top of your chassis via your choice.

Thank you for following my instructable, I hope you enjoy!

1 Person Made This Project!

Recommendations

  • Instrument Contest

    Instrument Contest
  • Make it Glow Contest

    Make it Glow Contest
  • STEM Contest

    STEM Contest

18 Discussions

0
None
rlafollette

6 months ago

Bluetooth won't connect?? Any suggestions?
I'm a fairly experienced user and have checked all the obvious things (code, circuit, Bluetooth ON,...) Would love to get this going, but BLE Joystick can't connect to the Bluetooth.

When BLE Joystick "finds" the Bluetooth module, what kind of name should I expect for the device. Maybe I'm finding other Bluetooth devices - not actually finding the module for this project???

I appreciate any thoughts or suggestions.

0
None
Sophjcc116

8 months ago

How did you attach the wires to the motor driver?
(I'm very new at circuits, BTW, so that was not obvious to me.)

1
None
IsaacB76

Tip 1 year ago

Here's the code with the errors removed:

//Code by Hunter Knott and based off of Owen Sobel's Bluetooth 4.0 code

//Updated by Isaac Burton

#define in1 5 //L298n Motor Driver pins

#define in2 6

#define in3 10

#define in4 11

#define LED 13

#define ena 9

#define enb 8

int command; //Int to store app command state.

int Speed = 204; // 0 - 255.

int Speedsec;

int buttonState = 0;

int lastButtonState = 0;

int Turnradius = 0; //Set the radius of a turn, 0 - 255 Note:the robot will malfunction if this is higher than int Speed.

int brakeTime = 45;

int brkonoff = 1; //1 for the electronic braking system, 0 for normal.

void setup() {

pinMode(in1, OUTPUT);

pinMode(in2, OUTPUT);

pinMode(in3, OUTPUT);

pinMode(in4, OUTPUT);

pinMode(ena, OUTPUT);

pinMode(enb, OUTPUT);

pinMode(LED, OUTPUT); //Set the LED pin.

Serial.begin(9600); //Set the baud rate to your Bluetooth module.

}

void forward() {

digitalWrite(in1, LOW);

digitalWrite(in2, HIGH);

analogWrite(ena, 255);

digitalWrite(in3, HIGH);

digitalWrite(in4, LOW);

analogWrite(enb, 255);

}

void back() {

digitalWrite(in1, HIGH);

digitalWrite(in2, LOW);

analogWrite(ena, 255);

digitalWrite(in3, LOW);

digitalWrite(in4, HIGH);

analogWrite(enb, 255);

}

void left() {

digitalWrite(in1, HIGH);

digitalWrite(in2, LOW);

analogWrite(ena, 0);

digitalWrite(in3, HIGH);

digitalWrite(in4, LOW);

analogWrite(enb, 255);

}

void right() {

digitalWrite(in1, HIGH);

digitalWrite(in2, LOW);

analogWrite(ena, 255);

digitalWrite(in3, HIGH);

digitalWrite(in4, LOW);

analogWrite(enb, 0);

}

void forwardleft() {

analogWrite(in1, Speedsec);

analogWrite(in3, Speed);

}

void forwardright() {

analogWrite(in1, Speed);

analogWrite(in3, Speedsec);

}

void backright() {

analogWrite(in2, Speed);

analogWrite(in4, Speedsec);

}

void backleft() {

analogWrite(in2, Speedsec);

analogWrite(in4, Speed);

}

void Stop() {

analogWrite(in1, 0);

analogWrite(in2, 0);

analogWrite(in3, 0);

analogWrite(in4, 0);

}

void brakeOn() {

//Here's the future use: an electronic braking system!

// read the pushbutton input pin:

buttonState = command;

// compare the buttonState to its previous state

if (buttonState != lastButtonState) {

// if the state has changed, increment the counter

if (buttonState == 'S') {

if (lastButtonState != buttonState) {

digitalWrite(in1, HIGH);

digitalWrite(in2, HIGH);

digitalWrite(in3, HIGH);

digitalWrite(in4, HIGH);

delay(brakeTime);

Stop();

}

}

// save the current state as the last state,

//for next time through the loop

lastButtonState = buttonState;

}

}

void brakeOff() {

}

void loop() {

if (Serial.available() > 0) {

command = Serial.read();

Stop(); //Initialize with motors stoped.

switch(command){

case 'a':

forward();

break;

case 'c':

back();

break;

case 'd':

left();

break;

case 'b':

right();

break;

case 'G':

forwardleft();

break;

case 'I':

forwardright();

break;

case 'H':

backleft();

break;

case 'J':

backright();

break;

case '0':

Speed = 100;

break;

case '1':

Speed = 140;

break;

case '2':

Speed = 153;

break;

case '3':

Speed = 165;

break;

case '4':

Speed = 178;

break;

case '5':

Speed = 191;

break;

case '6':

Speed = 204;

break;

case '7':

Speed = 216;

break;

case '8':

Speed = 229;

break;

case '9':

Speed = 242;

break;

case 'q':

Speed = 255;

break;

}

Speedsec = Turnradius;

if (brkonoff == 1) {

brakeOn();

} else {

brakeOff();

}

}

}

0
None
EpicDreamzP

Question 1 year ago on Step 7

Arduino: 1.8.5 (Windows 10), Board: "Arduino/Genuino Uno"

C:\Users\kes\Downloads\Bluetooth_RC_Code_with_iOS\Bluetooth_RC_Code_with_iOS.ino: In function 'void loop()':

Bluetooth_RC_Code_with_iOS:33: error: 'Stop' was not declared in this scope

Stop(); //Initialize with motors stoped.

^

Bluetooth_RC_Code_with_iOS:35: error: case label ''a'' not within a switch statement

case 'a':

^

Bluetooth_RC_Code_with_iOS:36: error: 'forward' was not declared in this scope

forward();

^

Bluetooth_RC_Code_with_iOS:37: error: break statement not within loop or switch

break;

^

Bluetooth_RC_Code_with_iOS:38: error: case label ''c'' not within a switch statement

case 'c':

^

Bluetooth_RC_Code_with_iOS:39: error: 'back' was not declared in this scope

back();

^

Bluetooth_RC_Code_with_iOS:40: error: break statement not within loop or switch

break;

^

Bluetooth_RC_Code_with_iOS:41: error: case label ''d'' not within a switch statement

case 'd':

^

Bluetooth_RC_Code_with_iOS:42: error: 'left' was not declared in this scope

left();

^

Bluetooth_RC_Code_with_iOS:43: error: break statement not within loop or switch

break;

^

Bluetooth_RC_Code_with_iOS:44: error: case label ''b'' not within a switch statement

case 'b':

^

Bluetooth_RC_Code_with_iOS:45: error: 'right' was not declared in this scope

right();

^

Bluetooth_RC_Code_with_iOS:46: error: break statement not within loop or switch

break;

^

Bluetooth_RC_Code_with_iOS:47: error: case label ''G'' not within a switch statement

case 'G':

^

Bluetooth_RC_Code_with_iOS:48: error: 'forwardleft' was not declared in this scope

forwardleft();

^

Bluetooth_RC_Code_with_iOS:49: error: break statement not within loop or switch

break;

^

Bluetooth_RC_Code_with_iOS:50: error: case label ''I'' not within a switch statement

case 'I':

^

Bluetooth_RC_Code_with_iOS:51: error: 'forwardright' was not declared in this scope

forwardright();

^

Bluetooth_RC_Code_with_iOS:52: error: break statement not within loop or switch

break;

^

Bluetooth_RC_Code_with_iOS:53: error: case label ''H'' not within a switch statement

case 'H':

^

Bluetooth_RC_Code_with_iOS:54: error: 'backleft' was not declared in this scope

backleft();

^

Bluetooth_RC_Code_with_iOS:55: error: break statement not within loop or switch

break;

^

Bluetooth_RC_Code_with_iOS:56: error: case label ''J'' not within a switch statement

case 'J':

^

Bluetooth_RC_Code_with_iOS:57: error: 'backright' was not declared in this scope

backright();

^

Bluetooth_RC_Code_with_iOS:58: error: break statement not within loop or switch

break;

^

Bluetooth_RC_Code_with_iOS:59: error: case label ''0'' not within a switch statement

case '0':

^

Bluetooth_RC_Code_with_iOS:61: error: break statement not within loop or switch

break;

^

Bluetooth_RC_Code_with_iOS:62: error: case label ''1'' not within a switch statement

case '1':

^

Bluetooth_RC_Code_with_iOS:64: error: break statement not within loop or switch

break;

^

Bluetooth_RC_Code_with_iOS:65: error: case label ''2'' not within a switch statement

case '2':

^

Bluetooth_RC_Code_with_iOS:67: error: break statement not within loop or switch

break;

^

Bluetooth_RC_Code_with_iOS:68: error: case label ''3'' not within a switch statement

case '3':

^

Bluetooth_RC_Code_with_iOS:70: error: break statement not within loop or switch

break;

^

Bluetooth_RC_Code_with_iOS:71: error: case label ''4'' not within a switch statement

case '4':

^

Bluetooth_RC_Code_with_iOS:73: error: break statement not within loop or switch

break;

^

Bluetooth_RC_Code_with_iOS:74: error: case label ''5'' not within a switch statement

case '5':

^

Bluetooth_RC_Code_with_iOS:76: error: break statement not within loop or switch

break;

^

Bluetooth_RC_Code_with_iOS:77: error: case label ''6'' not within a switch statement

case '6':

^

Bluetooth_RC_Code_with_iOS:79: error: break statement not within loop or switch

break;

^

Bluetooth_RC_Code_with_iOS:80: error: case label ''7'' not within a switch statement

case '7':

^

Bluetooth_RC_Code_with_iOS:82: error: break statement not within loop or switch

break;

^

Bluetooth_RC_Code_with_iOS:83: error: case label ''8'' not within a switch statement

case '8':

^

Bluetooth_RC_Code_with_iOS:85: error: break statement not within loop or switch

break;

^

Bluetooth_RC_Code_with_iOS:86: error: case label ''9'' not within a switch statement

case '9':

^

Bluetooth_RC_Code_with_iOS:88: error: break statement not within loop or switch

break;

^

Bluetooth_RC_Code_with_iOS:89: error: case label ''q'' not within a switch statement

case 'q':

^

Bluetooth_RC_Code_with_iOS:91: error: break statement not within loop or switch

break;

^

Bluetooth_RC_Code_with_iOS:95: error: 'brakeOn' was not declared in this scope

brakeOn();

^

Bluetooth_RC_Code_with_iOS:97: error: 'brakeOff' was not declared in this scope

brakeOff();

^

C:\Users\kes\Downloads\Bluetooth_RC_Code_with_iOS\Bluetooth_RC_Code_with_iOS.ino: At global scope:

Bluetooth_RC_Code_with_iOS:100: error: expected declaration before '}' token

}

^

exit status 1

'Stop' was not declared in this scope

This report would have more information with

"Show verbose output during compilation"

option enabled in File -> Preferences.

Could anyone please help me? thx.

0
None
AndrewJ159

2 years ago

THIS IS AWESOMEEEEEEEEEEEEEEEEEEE!

0
None
mikey116

2 years ago

Hi,

Even in your picture I see that

Bluetooth_RC_Code_with_iOS.ino

is missing a swtich statement for the variable named "command". I added it so it would compile. Yet, am unsuccessful at seeing the BLE Shield actually communicate with the Arduino in such a way as to fire one of the four inputs for the motor controller.

If you have a corrected .ino which perhaps would have some other problems corrected, could you please send me a link?

Thank you!

Mike

0
None
CJaco11

2 years ago

I have done everything, arduino is connected, motor module is up, bluetooth is connected, code is downloaded, but for some reason I cant get the battery to work. the board gets power when plugged into my computer, but I cannot seem to get the battery to work. i have tried many batteries so that is not the issue. Also, onI cannot find the bluetooth device and cannot connect to it. This is for a school project and I have a deadline soon, so any help would be greatly appreciated.

0
None
jfox1212

2 years ago

I get many errors when trying to upload my code, does anyone have any suggestions for this?

0
None
knutef

2 years ago

Help me im getting these errors when uploading to arduino!

Bluetooth_RC_Code_with_iOS.ino: In function 'void loop()':

Bluetooth_RC_Code_with_iOS:33: error: case label ''a'' not within a switch statement

Bluetooth_RC_Code_with_iOS:35: error: break statement not within loop or switch

Bluetooth_RC_Code_with_iOS:36: error: case label ''c'' not within a switch statement

Bluetooth_RC_Code_with_iOS:38: error: break statement not within loop or switch

Bluetooth_RC_Code_with_iOS:39: error: case label ''d'' not within a switch statement

Bluetooth_RC_Code_with_iOS:41: error: break statement not within loop or switch

Bluetooth_RC_Code_with_iOS:42: error: case label ''b'' not within a switch statement

Bluetooth_RC_Code_with_iOS:44: error: break statement not within loop or switch

Bluetooth_RC_Code_with_iOS:45: error: case label ''G'' not within a switch statement

Bluetooth_RC_Code_with_iOS:47: error: break statement not within loop or switch

Bluetooth_RC_Code_with_iOS:48: error: case label ''I'' not within a switch statement

Bluetooth_RC_Code_with_iOS:50: error: break statement not within loop or switch

Bluetooth_RC_Code_with_iOS:51: error: case label ''H'' not within a switch statement

Bluetooth_RC_Code_with_iOS:53: error: break statement not within loop or switch

Bluetooth_RC_Code_with_iOS:54: error: case label ''J'' not within a switch statement

Bluetooth_RC_Code_with_iOS:56: error: break statement not within loop or switch

Bluetooth_RC_Code_with_iOS:57: error: case label ''0'' not within a switch statement

Bluetooth_RC_Code_with_iOS:59: error: break statement not within loop or switch

Bluetooth_RC_Code_with_iOS:60: error: case label ''1'' not within a switch statement

Bluetooth_RC_Code_with_iOS:62: error: break statement not within loop or switch

Bluetooth_RC_Code_with_iOS:63: error: case label ''2'' not within a switch statement

Bluetooth_RC_Code_with_iOS:65: error: break statement not within loop or switch

Bluetooth_RC_Code_with_iOS:66: error: case label ''3'' not within a switch statement

Bluetooth_RC_Code_with_iOS:68: error: break statement not within loop or switch

Bluetooth_RC_Code_with_iOS:69: error: case label ''4'' not within a switch statement

Bluetooth_RC_Code_with_iOS:71: error: break statement not within loop or switch

Bluetooth_RC_Code_with_iOS:72: error: case label ''5'' not within a switch statement

Bluetooth_RC_Code_with_iOS:74: error: break statement not within loop or switch

Bluetooth_RC_Code_with_iOS:75: error: case label ''6'' not within a switch statement

Bluetooth_RC_Code_with_iOS:77: error: break statement not within loop or switch

Bluetooth_RC_Code_with_iOS:78: error: case label ''7'' not within a switch statement

Bluetooth_RC_Code_with_iOS:80: error: break statement not within loop or switch

Bluetooth_RC_Code_with_iOS:81: error: case label ''8'' not within a switch statement

Bluetooth_RC_Code_with_iOS:83: error: break statement not within loop or switch

Bluetooth_RC_Code_with_iOS:84: error: case label ''9'' not within a switch statement

Bluetooth_RC_Code_with_iOS:86: error: break statement not within loop or switch

Bluetooth_RC_Code_with_iOS:87: error: case label ''q'' not within a switch statement

Bluetooth_RC_Code_with_iOS:89: error: break statement not within loop or switch

Bluetooth_RC_Code_with_iOS.ino: At global scope:

Bluetooth_RC_Code_with_iOS:98: error: expected declaration before '}' token

0
None
eldho kurian

3 years ago

It is not working when we run code it says that stop is not declared in this scope

1 reply
0
None
into15

3 years ago

What type of motors did you use?

0
None
KNEXnCoding

3 years ago

Wow! I need to get my hands on that Bluetooth part. This is cool!

0
None
wold630

3 years ago

Wow! Thanks for simplifying this!