loading

I have always loved RC cars, but sadly I got to buy one when I was no more a kid. But it wasn't as cool as I expected. So I made my own RC car that can be controlled using a smartphone app. Here I'm sharing a step by step guide you can follow to make your own Bluetooth controlled car with Proportional Speed Control.

To complete this project, you should have some basic electronics knowledge. If you have never worked on Arduino then check out this instructable to learn the basics.

Required Hardware

  • L298 Dual H-bridge IC
  • 2 x 0.5 ohm 2W resistors
  • Arduino Uno, Nano or any other version with at least 2 pwm channels.
  • HC-05 Bluetooth module
  • 7.2V LiPo/Li-Ion battery (I used two mobile phone batteries connected in series)
  • Veroboard (prototype board) and soldering equipment
  • 2 x Tyre + motor
  • 1 x Caster wheel
  • Car chasis

If you want, you can skip the first two parts in the list and buy prebuilt Motor Driver Shield instead. It will save you from soldering.

Required Software

  • Arduino IDE

Step 1: Create the Motor Driver Circuit

Skip this step in case you choose to buy prebuilt Motor Driver Shield

H-Bridge is a circuit used to drive a motor in both directions. L298 makes H-Bridge circuit very simple. Use the given circuit diagram to create the motor driver circuit. You can use either perforated prototype board or PCB whatever you prefer.

Step 2: Program Arduino

We will use BlueDuino app to control our car via Bluetooth. This app works on any windows 10 device. If you wanna control it using android phone, you might need to tweak the Arduino code a bit according to the app you are using. Download the code (.ino file) and then upload it to Arduino. Make sure nothing is connected with the Rx pin of Arduino before you upload your code, otherwise upload will fail.

Reading a Chunk from Bluetooth

String ReadLine()
{
  String s;
  char c;
  while (1)
  {
    if (Serial.available())
    {
      c = Serial.read();
      if (c == '*')
      {
        continue;
      }
      else if (c == '#')
      {
        return s;
      }
      else
      {
        s += c;
      }
    }
  }
}

This function will return a string in a format like this: X,Y , where X and Y are single byte ASCII values of x-axis and y-axis of the joystick.

Getting Joystick Position

The app sends data in a format like this *X,Y# . Every command starts with * and ends with #. The app sends this string whenever the joystick is moved. Here X and Y are unsigned char. It's value can vary from 0-255. When the joystick is in mid then x-axis = 127, y-axis = 127. On serial monitor a command might look like this *a,<#

void UpdateAxis(int *x, int *y, String chunk)
{
  String s1, s2;
  bool comma;
  if (s.length() != 3) return;
  *x = (int)(byte)s[0] - 127;
  *y = (int)(byte)s[2] - 127;
}

x and y are stored as global variables in the Arduino code.

Translating Axis Values to Motor Speeds

Now we need to convert x-axis , y-axis values to drive motors using differential drive. When joystick is at extreme forward i.e. x-axis = 255, y-axis = 127, then both motors should have maximum speed in the forward direction.

void ToDifferentialDrive(int xValue, int yValue)
{
  if (yValue > 0)
  {
    if (xValue < 0)
    {
      left = mag + (HANDLING * xValue);
      right = mag;
    }
    else
    {
      left = mag;
      right = mag - (HANDLING * xValue);
    }
  }

  else
  {
    if (xValue < 0)
    {
      left = -mag;
      right = -mag - xValue;
    }
    else
    {
      left = -mag + xValue;
      right = -mag;
    }
  }
}

This function translates the x-axis and y-axis values into left and right motor speeds and updates the respective global variables. HANDLING is a constant that can be anywhere between 0-1. For me 0.6 is a suitable value.

Driving the Motors

Now finally we will use those speed values to drive the motors.

void DriveMotor(int motor, int spd, int maxSpeed)
{
  spd = 255 * ((double)spd / maxSpeed);  Serial.print(spd);
  Serial.print(" === \t");

  if (spd > 0)
  {
    analogWrite(motorPins[motor][0], spd);
    digitalWrite(motorPins[motor][1], LOW);
  }
  else
  {
    analogWrite(motorPins[motor][0], (255 + spd));
    digitalWrite(motorPins[motor][1], HIGH);
  }
}

maxSpeed determines the peak value of the left and right variables, which is 128. Increasing this value doesn't increase the speed, so don't change it!

Step 3: Connect the Circuit

  • Connect the Arduino and motor driver circuit (h-bridge) we created in step 1

Arduino --- Motor Driver Circuit

pin 5 ---------- pin 1

pin 6 ---------- pin 2

pin 9 ---------- pin 3

pin 10 -------- pin 4

5V ------------ pin 5

GND--------- pin 6

  • Now connect motors with H-Bridge

Motor Driver ---- Motor

Out 1 ---------------- Motor 1 pin 1

Out 2 ---------------- Motor 1 pin 2

Out 3 ---------------- Motor 2 pin 1

Out 4 ---------------- Motor 2 pin 2

  • OR If you are using Motor Driver Shield:

Arduino ---- Motor Driver Shield

pin 5 ---------- Input 1

pin 6 ---------- Input 2

pin 9 ---------- Input 3

pin 10 -------- Input 4

5V ------------ 5V

GND--------- GND

Note: Also connect battery +ve to the terminal specified in the picture above and battery -ve to GND.

In case the motor turns opposite, swap the motor terminals for the respective motor.

  • Connect the Bluetooth module (HC-05/HC-06) to Arduino as:

Arduino ---- Bluetooth Module

Tx ---------------- Rx

Rx ---------------- Tx

3.3V ------------- Vcc

GND ------------ GND

Now you can power the Arduino directly through the battery using the power jack. On power jack, Arduino can bear upto 20V but the recommended voltage is 7-12V.

Step 4: Assemble the Car

Now we have everything ready, let's assemble our car. My car is ugly as I don't like to spend my time on decorating it but of course you can break convention of the geeks and make it beautiful.

Start Driving!

Now download BlueDuino app from windows store. If you want to control the car using an Android or iPhone then you might need to tweak the code a bit according to the app you are using.

1. Pair your phone to your HC-05 and connect using mobile phone settings. Default pairing code is 1234.

2. Open the app and connect to your HC-05 from app.

3. Go to joystick tab in the app and control your car using joystick!

If you experience problem in step one then make sure your device supports Bluetooth Smart Ready not Bluetooth Smart (BLE) and also check if Bluetooth is turned on. If your device is Bluetooth Smart then you require BLE module which is currently not supported by the app.

<p>Hello</p><p>Nice job, but EVERYTHING would be so nice if there was a video tutorial and this NOT user-friendly system of &quot;next page&quot; &quot;next page&quot; etc with pictures with no numbers etc. A complete video tutorial and propably a visuino simulation is the best way to understand better what you are doing. thanks</p>
<p>Nice Job!</p>
<p>what is the rpm of motor you used?</p>
<p>i used tyre+motor kit like this: </p><p><a href="http://www.ebay.com/itm/2-pcs-Smart-Car-Robot-Plastic-Tire-Wheel-with-DC-3-6v-Gear-Motor-for-Arduino-/401244422402">http://www.ebay.com/itm/2-pcs-Smart-Car-Robot-Plas...<br></a></p><p>rpm is proportional to the joystick position w.r.t center.. max rpm is around 200.. <br></p>
<p>what is the android app equivalent to bluedruino??</p>
<p><a href="https://play.google.com/store/apps/details?id=com.nudge.me.JSP">https://play.google.com/store/apps/details?id=com....</a></p><p><a href="https://play.google.com/store/apps/details?id=eu.jahnestacado.arduinorc">https://play.google.com/store/apps/details?id=eu.j...</a></p><p>These<br> two apps seems to be pretty similar.. but you would require to tweak <br>the code according to the format the app uses to send data</p>
<p>Good.</p>
<p>You got some pretty good maneuverability out of this!</p>
<p>thanks :) it was my first instructable</p>
Give me ur number or please call me 9807322338 please bro help in my project
<p>haha ok.. u can contact me on fb </p><p>https://www.facebook.com/ehassaan</p>

About This Instructable

4,801views

73favorites

License:

Bio: Electronics + Software development + Physics + little bit of everything
More by Hassaan Akbar:Create Your Own VR Game Controller Using Arduino Smartphone Controlled Car with Proportional Speed Control 
Add instructable to: