Bluetooth RC Car in Mbed Platform

by CraftTechEngineer in Circuits > Remote Control

851 Views, 0 Favorites, 0 Comments

Bluetooth RC Car in Mbed Platform

linuxsm.jpg
WhatsApp Image 2020-12-23 at 1.20.40 PM.jpeg

Welcome! In this Instructable I will show you how to make a RC bluetooth-controlled car which can be used as a small delivery truck, to develop your skills or to impress your friends.

I carried out this project in the worldwide reknown mbed platform which utilizes the C++ programming language to control the NUCLEO board integrating the ARM OS microprocessors. Also, half of this project was made in arduino so you can create your own version in this platform.

Supplies

  • Board Nucleo STM32F411re (stmicroelectronics)
  • MicroUSB cable for NUCLEO board.
  • Jumper wires
  • 2x Protoboard
  • LCD 16x2 Display
  • 30kOhms Potentiometer
  • Bluetooth slave module HC-06
  • L293D Dual Motor PWM driver
  • 2x DC motor
  • 2x 9V Batteries
  • Power bank

Testing the BT Module

BT Test.jpg
BT Connections.png

In order to verify the correct functioning of the Bluetooth module, we have to test it in a very easy circuit. This will be to turn on and off an LED.

To build the circuit we only need a 220 Ohm Resistor and (of course) the LED, any color you like. I used a white LED. The connections diagram is shown in the image annexed. Remember the anode goes with the resistor to Vcc.

It is optional to place an LED because the output pin is the integrated LED in the NUCLEO Board

Here is the repository for the code, you have to click on "main.cpp" file: https://os.mbed.com/users/brandongarcia/code/Blue...

An here is a video of the demonstration uploaded in my YT channel:

For the BT manager app I recommend using the "Bluetooth SPP Manager" developed by Jürgen Hausladen, but any Bluetooth SPP app will work perfectly.

Testing the LCD Display

LCD Pinout.jpg
LCD Conns.png
LCD test.png

The LCD is intended to show the direction in which the RC car turns. For the sake of simplicity, the guidance is set with a standard AWSD keyboard configuration.

A = Turn left

W = Forward

S = Backward

D = Turn right

The code library repository for NUCLEO is in this URL: https://os.mbed.com/users/brandongarcia/code/LCD_H...

*NOTE*: You'll have to import also into your compiler the TextLCD library for the code to work properly.

The above code shows the pins used. As you can see in the pinout configuration, all of them correspond to the Analog pins. The first ones are reserved for the RS (Register Select) and E (Enable) and the following ones for the data display. The LCD uses 8 pins for displaying information D0 through D8. We will be using only the D4-D8 pins.

Additionally, the potentiometer must be added in this circuit in order to adjust the contrast of the screen. This connection goes to the 3rd pin of the LCD.

You can follow the connections shown in the image above. Also, here is the demonstration in Tinkercad and the ARDUINO code: https://www.tinkercad.com/things/izzkXw9VNRI-lcd-d...

*2nd NOTE*: I recommend using another external power source for the LCD because while working simultaneously with the DC motors and BT the LCD started to blink and by connecting it to an external source this issue was corrected.

*3rd NOTE*: I HIGHLY recommend using some tape or any other material to keep your cables tied together. This helps you in two ways. It prevents things to get messy and gives you clarity on the connections between components.

Testing the DC Motors

DC Motors.jpg
L293D.jpg

The DC motors are controlled using the PWM technique. This method prevents a sooner drain of the power source by working on intervals. In this project, PWM is used at 25%working-cycle time with a period of 8s seconds, this means that the DC motor will be working continuosly for 2 seconds and remain 8 seconds off. But for the initial tests, the cycle is set up to 50% with the same period. (You can read more about PWM in this article: https://lastminuteengineers.com/l293d-dc-motor-ard...).

To control both components we must use a dual driver, this is the L293D. It is symmetrical and one side is completely for one motor, the datasheet showing the working diagram of this component is shown in the images included. It has two enable pins and two control pins and by changing the values of the control pins (1 --> 0 or 0 --> 1) you change the polarity and alternate between CW or CCW. Besides, it needs an additional power source greater than 5V to move both motors, in this project I recommend using a 9V Battery or you can also use 12V by creating different combinations of AA batteries or 1 9V and 2 AA.

Here is the code for NUCLEO: https://os.mbed.com/users/brandongarcia/code/PwmOu...

You can use it only with one side or both sides at the same time, of course you will have to declare any other unoccupied pins you have.

Also here is the demonstration in Tinkercad, which includes the code working in ARDUINO: https://www.tinkercad.com/things/izzkXw9VNRI-lcd-d...

Merging the Code

Here is the complete code for the overall project including the BT module, LCD and both DC motors.https://os.mbed.com/users/brandongarcia/code/FULL_...

As you can see it is merely a conjunction of them three systems that depend on the user's single input.

*NOTE* This project was intended for the microprocessors and microcontrollers course in college where we worked only with the NUCLEO board, that's why the complete code is only written in mbed platform. Nevertheless, I already provided you all the other three systems' code so it is a challenge for you to implement the full version in Arduino :)

Remember that every programmer has its own ways, maybe you find out an easier way to implement the code or maybe you want to implement a different configuration

Full Connections Diagram

Full connections diagram.png
WhatsApp Image 2020-12-23 at 1.01.06 PM (2).jpeg

In this diagram you can see all the connections done for the project.

Building the Structure

WhatsApp Image 2020-12-23 at 1.20.40 PM.jpeg

You can use any box or container for your car, or you can even leave it without a chassis. I used a mall cardboard box from a package I ordered online. It is out on your creativenesso find something that best suit your needs. One great characteristic of an engineer is to use its creativity to work out solutions! :)

On the picture of my model, you can notice it only has two big wheels. I ran out of materials and had to improvise and decided to attach a Hot Wheels toy car (lol) in the front but it wasn't the best solution due to the high friction with the floor.

Rollin' Out!

All it's left to be done is to test it out. Open the Bluetooth SPP app and connect your device listed as "HC06".

Perhaps you'll encounter some problems throughout the way but it's inherent to every process and it is part of learning. Don't give up if something doesn´t work out the way you expected, keep trying! You can contact me anytime you want if you have doubts and I'll answer as fast as possible.

Good Luck!

Demonstration videos: