Arduino Bluetooth Robot Car

2,653

20

1

Introduction: Arduino Bluetooth Robot Car

Build your 1st Arduino Robot Car!

The most complete and comprehensive step-by-step visual instructions to build your 1st Arduino Bluetooth Robot Car. Enjoy!

Step 1: Project Overview

A robot car chassis contains the bottom frame, upon which the motors that drive the tires/wheels are attached. The motors are connected to a powered Motor Drive Shield that is connected (piggyback style) to the Arduino UNO board. A Bluetooth receiver module is connected to the Arduino board as well. The Arduino is programmed to receive Bluetooth signals from an Android app, and switch on/off the motors, hence rotating the wheels and moving the car.

Step 2: Methodology: Get, Prepare, Assemble!

  • Get Components: Gather all the components upfront to complete the project.
  • Prepare Modules: Attach connectors to all the modules that are linked together.
  • Assemble Project: Sequence the assembly to ensure smooth and easy connections.

Step 3: Components

  • Arduino Uno R3 Board: The project uses Freenove UNO R3, but any Arduino-compatible board will do. The Arduino contains the project code, reads (input) Bluetooth signals from the Bluetooth module and writes (output) signals to the motor shield.
  • L293D Motor Drive Shield: The project uses Gikfun Motor Drive Shield Expansion Board L293D for Arduino UNO. The motor shield reads (input) signals from the Arduino board and drives (output) servos that rotate the wheels.
  • HC-05 Bluetooth Wireless: The project uses the DSD-Tech HC-05 Bluetooth Serial Pass-Through Module. The Bluetooth module receives (input) Bluetooth signals from Android app and sends (output) signals to Arduino board.
  • Robot Car Kit: The kit contains a chassis, motors, tyres/wheels, wires, screws, nuts, etc. A basic kit includes a chassis (maybe 2), 4 motors, 4 wheels, and nuts, bolts, screws and 2 wires per motor.
  • Batteries: Two batteries: a 9V for the Arduino board and a 4 AA unit for the Motor Shield. A 9V battery drives the Arduino, and a unit of 4 AA batteries drives the motor shield.
  • Android App: Android Bluetooth RC Controller app to send Bluetooth signals to the robot car. The app controls the robot car movements (go forward, go backward, turn left, turn right).

Step 4: Preparations: Overview

The robot car is usually sold (eBay, Amazon, Banggood, etc.) either as a basic kit (chassis, motors, wheels, nuts, bolts, wires but NO boards) or a complete kit (with Arduino, Motor Shield, Bluetooth, Batteries, Assembly instructions and, optionally, other sensors). The assembly is the same, as long as you have all the components.

Step 5: Motor Wires

Each motor needs to be connected to 2 wires: Ground and Voltage. For consistency, connect (by soldering or hooks) the positive Voltage wire (red) to the top motor connector and the negative Ground wire (black, blue, or any other color) to the bottom motor connector.

Do this BEFORE assembly, each motor individually. If after assembly, soldering the bottom wire connection can be a bit tricky (but doable!). It's also advisable to solder the wires vertically (pointing up, not sideways) hence providing more length of wire making it easier to connect the other end to the Motor Shield.

Step 6: Bluetooth Wires

The HC-05 Bluetooth module needs 4 wires:

RX &TX: Female (from HC-05 side) to Male (Motor Shield TX & RX header pins).

VCC & GND: Female (from HC-05 side) to Female (Motor Shield Servos + & - pins).

Step 7: Motor Shield Wires

The Motor Shield will sit on top of the Arduino board (piggyback), so its GPIOs (pins) will correspond to the Arduino board beneath it. We cannot, or do not want, to solder the Arduino board pins directly.

So, we need to solder a 2-pin Header to GPIO 0 & 1 on the Motor Shield (hence connecting to the Arduino RX & TX pins, respectively, underneath). These will later connect to the HC-05 Bluetooth TX & RX pins (so, in reverse order: Bluetooth RX to Arduino TX, and Bluetooth TX to Arduino RX).

Step 8: Arduino Logic Code

The Arduino needs to read input signals (Bluetooth) and write output commands to the motors to move the wheels. The code can be copy pasted from the box below into the Arduino IDE on your Mac/PC, then uploaded to the Arduino board.

The code needs the AFMotor library (AF = Ada Fruit). This is a standard library and can be installed directly from the Arduino IDE (no external links needed). Navigate Sketch > Include Library > Manage Libraries, then search from Adafruit Motor Shield. Install Version 1.0.1 (not 2.0) for this project. Then copy/paste the code below into a new IDE project file, Verify then Upload. Once upload is successful, disconnect the Arduino board (as it will retain the code in its memory). The Arduino is now ready as a standalone device.

Step 9: Android Arduino Bluetooth RC Car App

On an Android phone, navigate to Google Play Store and download the Arduino Bluetooth RC Car app.The app will later pair with the HC-05 Bluetooth module once connected to the Arduino/Motor Shield. The app will allow you to control the car movements.

Step 10: Batteries

You will need 2 battery units:

A 9V battery with battery snap that will power the Arduino board.

A 4xAA battery holder (or whatever your Robot Car Kit needs) to power the Motor Shield. The wires may need to be crimped to ensure they fit inside the Motor Shield pin securely.

Step 11: Assembly: Overview

The sequence of assembly is important to ensure a smooth progress to a successful project end. So,

1. Start with the chassis (motors, wheels)

2. Link the Motor Shield to the Arduino board.

3. Link the Motors to the Motor Shield

4. Link the HC-05 Bluetooth module to the Motor Shield

Step 12: Robot Car Kit

The kit will most likely have assembly instructions, but they generally adhere to the following steps:

1. Decide on Front and Back of car (in photo, Front is pointing up as in going forward from the viewer perspective).

2. Mark the Motors as Left Front, Left Back and Right Front, Right Back. This is to facilitate the connections to the Motor Shield Left and Right sides.

3. Assemble each motor in turn, noting the placement as in photo (the front motors face backwards, the back motors face forwards). For each motor:

3.1 Place the motor on the chassis

3.2 Secure with the brackets on each side

3.3 Add the screw and nuts and fasten to fix motor in place

3.4 Add the speed encoder (black/gray circle)

3.5 Attach the wheel to the outward motor side

Step 13: Arduino & Motor Shield

The Motor Shield will piggyback the Arduino board. Place the Motor Shield on top of the Arduino ensuring the proper alignment of pins: The Motor Shield 0 RX and 1 TX pins on top of Arduino 0 RX and 1 TX pins.

Push gently downward until the 2 boards are securely aligned and connected. When done, the Motor Shield LEFT will be on top of Arduino 9V battery input.

Fix a small empty box in the middle of the chassis and position the Arduino/Motor Shield combo on top (slightly above the motors).

Ensure the Bluetooth RX/TX is facing the front of the car, and the Arduino 9V battery input to the Left of the car. The Motor Shield M1 & M2 pins are now on the Left of the car, and the M3 & M4 pins are now on the Right of the car.

Step 14: Motor Shield Wiring

The Motor Shield has 4 motor connectors: M1, M2 on the Left side and M3, M4 on the Right side. The motor has a -ve yellow wire and a +ve red wire (see photo). The 1st pin of each M is the pin facing outwards (e.g. M1/M4 1st pin faces Front, M2/M3 1st pin faces Back).

M1 connects the Left Front motor: 1st pin -ve, 2nd pin +ve

M2 connects the Left Back motor: 1st pin -ve, 2nd pin +ve

M3 connects the Right Back motor: 1st pin -ve, 2nd pin +ve

M4 connects the Right Front motor: 1st pin -ve, 2nd pin +ve

The correct Mx connections are important to ensure that the wheels rotate in the correct direction together. For example, when the car is to move forward, all the wheels should rotate counter clockwise, and the reverse is true for backward movement.

Step 15: HC-05 Bluetooth Wiring

The HC-05 Bluetooth module needs 4 wires: RX & TX connect to Arduino/Motor Shield TX & RX, GND & VCC to Motor Shield Servos - & + pins. On the Front Left side of the Motor Shield there are 2 clusters of 3 pins each; it's the 2nd cluster (closer to the USB port) that needs to be connected, the leftmost pin is -ve and the rightmost is +ve).

Bluetooth RX (black) -> Motor Shield 2-Pin Header 1 (TX)

Bluetooth TX (red) -> Motor Shield 2-Pin Header 0 (RX)

Bluetooth GND (brown) -> - Servos (leftmost pin)

Bluetooth VCC (red) -> + Servos (rightmost pin)

Step 16: Batteries Wiring

Fix (using Blu Tack, double-sided tape or glue) the 9V battery to the Front of the car. Connect the battery snap to the Arduino 9V battery input socket (on the Left side of the car). The Motor Shield green light will go on the Bluetooth module (usually red) light will start flashing (indicating ready to pair).

Fix the 4 AA battery pack to the Back of the car. Connect the pack negative (black) and positive (red) wires to the Motor Shield battery pins (2 blue pins facing the Back of the car). The right pin marked GND connects to the black wire, the other left pin to the red wire.

Step 17: Testing & Driving

The car is now ready! But to make it actually move, we need to pair it's Bluetooth module with the Android app. Ensure the Bluetooth module light is flashing on/off indicating it's searchable and ready to pair.

1. Navigate to your Android phone Settings > Bluetooth and search for the car Bluetooth module. In our project, the module is DSD TECH HC-05, the password/pin is usually 1234 (if not, then 0000). Pair the Android phone with the HC-05.

2. Launch the Bluetooth RC Car app, navigate to Settings (cog icon menu) then from the Options Menu select 'Connect to Car'. If all is well, the connection is made (Bluetooth flashing stops) and the big red circle top left of app screen will turn to green.

3. Place the car chassis on top of a thin long box on your desk, so the box is in the middle of the chassis and the wheels can rotate freely around it. Test the connection by tapping each Forward, Backward, Right and Left button on the app screen. Watch video for visuals.

4. If the wheels are all rotating correctly (e.g. counter clockwise for forward) then place the car on a smooth surface (marble, vinyl, wood, NOT carpet) and drive the car around. Enjoy!

Step 18: How It Works

The Bluetooth RC Controller app sends the following commands (in the form of characters) to the car bluetooth module HC-05:

'F' to go forward

'B' to go backward

'L' to turn left

'R' to turn right

'S' to stop the car

Refer to the app Settings for more commands that you can add to the Arduino code.

The Arduino board logic reads the Bluetooth HC-05 input (continuously in the loop() function), using the RX/TX connections, and instructs the Motor Shield to move the motors/wheels to execute the command. For example, to turn left the Arduino moves motors M1 and M2 forward and motors M3 and M4 backward.

Be the First to Share

    Recommendations

    • Halloween Contest

      Halloween Contest
    • 3D Printed Student Design Challenge

      3D Printed Student Design Challenge
    • First Time Author Contest

      First Time Author Contest

    Comments