بناء سيارة روبوت يتم التحكم بها عبر البلوتوث باستخدام أردوينو، وHC-05، ودرع محرك Adafruit

Watch the full build: Bluetooth-controlled robot car with Arduino, HC-05, and Adafruit Motor Shield

Have you ever wanted to build a robot car you can drive from your phone? In this step-by-step Arduino Bluetooth robot car tutorial, you will build a fully functional سيارة روبوت يتم التحكم فيها عبر البلوتوث باستخدام أردوينو أونو, ، أن وحدة بلوتوث HC-05, و لوحة محرك Adafruit الإصدار 1.2. This is one of the most rewarding DIY Bluetooth controlled car Arduino projects for beginners and hobbyists alike.

Have you ever wanted to build a robot car you can drive from your phone? In this step-by-step Arduino Bluetooth robot car tutorial, you will build a fully functional سيارة روبوت يتم التحكم فيها عبر البلوتوث باستخدام أردوينو أونو, ، أن وحدة بلوتوث HC-05, و لوحة محرك Adafruit الإصدار 1.2. This is one of the most rewarding DIY Bluetooth controlled car Arduino projects for beginners and hobbyists alike.

This complete guide walks you through every stage of the build: assembling the four-wheel-drive chassis, wiring the motors and Bluetooth module, uploading the Arduino code, and creating a custom Android control app with MIT App Inventor. By the end, you will have a wireless robot car that responds to forward, backward, left, right, and stop commands from your smartphone. If you are new to Arduino, consider starting with our دليل أساسيات برمجة أردوينو first.

ما ستتعلمه

By following this HC-05 robot car Arduino tutorial from start to finish, you will learn how to:

  • Build a four-wheel-drive robot car chassis using Plexiglas and 3D-printed mounts
  • Understand how the Adafruit Motor Shield controls four DC motors simultaneously
  • Wire the HC-05 Bluetooth module to the Arduino for wireless serial communication
  • Write Arduino code that interprets single-character Bluetooth commands and drives motors accordingly
  • Build a simple Android control app using MIT App Inventor with directional buttons
  • Test, tune, and troubleshoot the finished Bluetooth controlled robot car

How the Bluetooth Robot Car Works

Before you start building, it helps to understand how all the parts work together in this Adafruit Motor Shield robot car project. The system has four main components: the Android phone, the HC-05 Bluetooth module, the Arduino Uno, and the Adafruit Motor Shield with four DC motors.

ال Android phone runs a custom app built with MIT App Inventor. When you press a directional button (forward, backward, left, or right), the app sends a single character command (F, B, L, R, or S for stop) over Bluetooth.

ال وحدة بلوتوث HC-05 receives that command wirelessly and passes it to the Arduino through the serial connection on pins 0 (RX) and 1 (TX). The HC-05 acts as a wireless serial bridge between the phone and the Arduino. To learn more about how the HC-05 and HC-06 modules work, see our complete HC-05/HC-06 Arduino Bluetooth tutorial.

ال أردوينو أونو reads the incoming character from the serial buffer. Based on the command received, it calls the appropriate movement function (forward, backward, turnLeft, turnRight, or stop).

ال لوحة محرك Adafruit الإصدار 1.2 sits on top of the Arduino and drives four DC motors through its M1, M2, M3, and M4 output terminals. The shield uses the AFMotor library to control motor direction (FORWARD, BACKWARD, RELEASE) and speed (0–255). In this project, the left-side motors connect to M1 and M2, and the right-side motors connect to M3 and M4. For turning, one side runs forward while the other runs backward, creating a tank-style turn. For a deeper look at motor driver principles, see our L298N motor driver tutorial with Arduino.

المكونات المطلوبة (قائمة المواد)

Below is the complete bill of materials for this DIY Bluetooth controlled car Arduino project. Most components are widely available online or in electronics starter kits.

عنصرالكميةمطلوب؟غايةملحوظات
أردوينو أونو1مطلوبMain microcontrollerAny Uno-compatible board works
لوحة محرك Adafruit الإصدار 1.21مطلوبDrives four DC motorsStacks directly on top of the Arduino
وحدة بلوتوث HC-051مطلوبWireless serial communication with phoneHC-06 also works (slave-only)
DC Motors with Gearboxes4مطلوبDrive the four wheelsTypically 3–6 V geared motors
عجلات4مطلوبAttach to motor shaftsMatch to your gearbox shaft size
Plexiglas Sheet1مطلوبRobot car chassis / base plateCut to desired size; acrylic or similar works
3D-Printed Motor Mounts4خياريSecure motors to chassisCan substitute with metal L-brackets
3D-Printed Arduino Holder1خياريMount Arduino to chassisDouble-sided tape or standoffs also work
Battery Pack (4×AA or similar)1مطلوبPowers motors and Arduino6 V pack recommended; use fresh batteries
أسلاك توصيلعديدمطلوبConnect HC-05 to ArduinoMale-to-female for HC-05 header pins
Screws, Nuts, Standoffsتشكيلة متنوعةمطلوبالتجميع الميكانيكيM3 size is common
Android Smartphone1مطلوبRuns the MIT App Inventor control appMust support Bluetooth Classic
3D rendering of the four-wheel-drive Bluetooth robot car chassis showing the Plexiglas base plate, four yellow DC motors with gearboxes, and wheel placement before electronics are mounted
3D rendering of the robot car chassis with four DC motors and wheels, ready for electronics assembly

Step 1: Building the Chassis

The chassis is the structural foundation of your Bluetooth-controlled robot car. In this project, we use a flat Plexiglas (acrylic) sheet as the base plate. Plexiglas is lightweight, easy to cut, and rigid enough to support all four motors plus the electronics.

Cut the Base Plate

Measure and cut the Plexiglas sheet to your desired dimensions. A typical size is around 20 cm × 15 cm, but you can adjust this depending on the size of your motors and battery pack. Use a saw or acrylic cutter for clean edges.

Prepare the Motor Mounts

Design and 3D-print motor mounts that securely hold your DC motors against the chassis. If you do not have a 3D printer, you can use metal L-brackets or even hot glue as a temporary solution. The mounts should grip the motor body firmly so the gearbox shafts point outward through the chassis edges.

Prepare the Arduino Holder

Design and 3D-print a holder to mount the Arduino Uno on the chassis. The holder keeps the Arduino secure during movement and prevents loose wiring. Alternatively, use standoffs with M3 screws through the Arduino mounting holes, or simply attach the board with double-sided foam tape.

الخطوة الثانية: تركيب المحركات

With the chassis prepared, attach the four DC motors to the base plate.

Attach Motors to Mounts

Use screws and nuts to secure each DC motor into its 3D-printed mount (or L-bracket). Make sure the motor shafts point outward and that all four motors are oriented the same way so the wheels spin in the expected direction.

Mount the Motor Assemblies on the Chassis

Attach the motor mounts to the Plexiglas chassis using screws and nuts. Position two motors on each side of the chassis, as far apart as possible for stability. Check that the wheels can spin freely without rubbing on the base plate or each other.

الخطوة 3: تركيب لوحة أردوينو ولوحة المحرك

Now secure the Arduino Uno and the Adafruit Motor Shield to the chassis.

Secure the Arduino Holder

Attach the 3D-printed Arduino holder (or standoffs) to the center or rear of the chassis. Leave enough room at the front or sides for the battery pack.

Place the Arduino and Shield

Set the Arduino Uno into the holder and secure it with screws. Then place the Adafruit Motor Shield on top of the Arduino, pressing it down gently to ensure all header pins are properly aligned and fully seated. The shield should sit flush with no pins misaligned.

الخطوة الرابعة: توصيل المكونات

Wiring the components correctly is one of the most critical steps in building your Bluetooth-controlled robot car. This section covers the motor connections, HC-05 Bluetooth wiring, and power connections. Use the wiring diagram below as a reference.

Wiring diagram for the Bluetooth robot car showing four DC motors connected to Adafruit Motor Shield terminals M1 through M4, HC-05 Bluetooth module wired to Arduino pins 0 and 1, and battery pack connected to the motor shield power terminals
Complete wiring diagram: four DC motors to Motor Shield, HC-05 to Arduino serial pins, and battery pack to shield power input

توصيلات المحرك

محركمحطة الدرعPosition on Car
Motor 1M1Left side (front or rear)
Motor 2M2Left side (front or rear)
Motor 3M3Right side (front or rear)
Motor 4M4Right side (front or rear)

Connect the two left-side motors to terminals M1 and M2, and the two right-side motors to terminals M3 and M4. Each motor has two wires; insert them into the screw terminals on the shield and tighten securely.

HC-05 Bluetooth Module Connections

دبوس HC-05دبوس أردوينوملحوظات
VCC5 فولتPowers the HC-05 module
أرضيأرضيأرضية مشتركة
TXDRX (Pin 0)HC-05 transmits data to Arduino
RXDTX (Pin 1)Arduino transmits data to HC-05

Important: Hardware Serial (Pins 0/1) and Upload Conflicts

Warning: In this project, the HC-05 is connected to Arduino pins 0 (RX) and 1 (TX). These are the same pins used by the USB serial connection for uploading sketches and Serial Monitor communication. This means you must disconnect the HC-05 module (at least the RX/TX wires) every time you upload new code to the Arduino. If the HC-05 stays connected during upload, the upload will fail because the Bluetooth module interferes with the USB serial data. After uploading, reconnect the HC-05 and reset the Arduino. Also, you will not be able to use Serial Monitor for debugging while the HC-05 is connected to pins 0/1. If you need simultaneous Bluetooth and Serial Monitor, use the SoftwareSerial library on different pins (for example, pins 2 and 3). For more details on wiring and using the HC-05 module, refer to our HC-05/HC-06 Arduino Bluetooth tutorial.

توصيلات الطاقة

Connect the positive and negative terminals of the battery pack to the power input terminals on the Adafruit Motor Shield. The shield passes power to the motors and can also power the Arduino through its onboard regulator. Make sure the ground connections between the battery pack, the shield, and the Arduino are all common. Use fresh batteries (6V recommended) for reliable motor performance.

الخطوة 5: تشغيل السيارة التي يتم التحكم فيها عبر البلوتوث

For this robot car project, a 4xAA battery pack (6 V total) is a practical and affordable power source. Connect the battery pack to the external power terminals on the Adafruit Motor Shield. The shield distributes power to the motors and can supply the Arduino through its power jumper. Make sure the power switch (if using one) is accessible so you can turn the car on and off easily. Avoid using 9 V block batteries because they do not provide enough current for four DC motors under load. If you want longer run time or higher torque, consider a rechargeable Li-ion pack with a voltage regulator.

الخطوة 6: برمجة أردوينو للتحكم عبر البلوتوث

The Arduino sketch below receives single-character commands from the HC-05 Bluetooth module over the hardware serial connection and drives the four DC motors accordingly. This code forms the brain of your Bluetooth controlled robot car. For a broader introduction to controlling DC motors with Arduino, see our tutorial on DC motor control with the L298N driver and Arduino Motor Shield.

مهم: Disconnect the HC-05 module from pins 0 and 1 before uploading this sketch. Reconnect after the upload completes, then reset the Arduino.

/**
 * Author: Omar Draidrya
 * Date: 2024/07/03
 * Bluetooth-controlled 4WD robot car using Adafruit Motor Shield V1.2 and HC-05.
 * Receives single-character commands (F/B/L/R/S) via serial from the HC-05
 * Bluetooth module and drives four DC motors on terminals M1-M4 accordingly.
 */
#include <AFMotor.h>
AF_DCMotor motor1(1);  // Create motor #1 using M1 connector
AF_DCMotor motor2(2);  // Create motor #2 using M2 connector
AF_DCMotor motor3(3);  // Create motor #3 using M3 connector
AF_DCMotor motor4(4);  // Create motor #4 using M4 connector
char command;
void setup() {
    Serial.begin(9600);  // Start serial communication at 9600 baud rate
    motor1.setSpeed(255);  // Set initial motor speeds
    motor2.setSpeed(255);
    motor3.setSpeed(255);
    motor4.setSpeed(255);
}
void loop() {
    if (Serial.available() > 0) {
        command = Serial.read();  // Read the incoming command
        if (command == 'F') {
            forward();
        } else if (command == 'B') {
            backward();
        } else if (command == 'L') {
            turnLeft();
        } else if (command == 'R') {
            turnRight();
        } else if (command == 'S') {
            stop();
        }
    }
}
void forward() {
    motor1.run(FORWARD);
    motor2.run(FORWARD);
    motor3.run(FORWARD);
    motor4.run(FORWARD);
}
void backward() {
    motor1.run(BACKWARD);
    motor2.run(BACKWARD);
    motor3.run(BACKWARD);
    motor4.run(BACKWARD);
}
void turnLeft() {
    motor1.run(BACKWARD);
    motor2.run(BACKWARD);
    motor3.run(FORWARD);
    motor4.run(FORWARD);
}
void turnRight() {
    motor1.run(FORWARD);
    motor2.run(FORWARD);
    motor3.run(BACKWARD);
    motor4.run(BACKWARD);
}
void stop() {
    motor1.run(RELEASE);
    motor2.run(RELEASE);
    motor3.run(RELEASE);
    motor4.run(RELEASE);
}
    

Code Explanation: AFMotor Library and Motor Setup

The code includes the <AFMotor.h> library, which is the Adafruit Motor Shield library. This library provides a simple interface to control DC motors connected to the shield. Four motor objects are created: motor1(1) through motor4(4), corresponding to the M1 to M4 terminals on the shield. In setup(), the serial communication is initialized at 9600 baud (matching the HC-05 default baud rate), and all four motors are set to full speed (255 out of 255).

Code Explanation: Motor Mapping (M1 to M4)

Motors 1 and 2 (M1, M2) are the left-side motors, and motors 3 and 4 (M3, M4) are the right-side motors. This mapping is important because the turning logic depends on driving the left and right sides independently. If your car turns the wrong way or drives backward when you expect forward, you can swap the motor connections at the shield terminals or swap the FORWARD/BACKWARD constants in the code.

Code Explanation: Bluetooth Command Protocol

The command protocol is straightforward: the app sends a single ASCII character, and the Arduino reads it from the serial buffer in حلقة(). The five commands are F (forward), B (backward), L (turn left), R (turn right), and S (stop). This simple single-character protocol is fast and reliable for real-time control.

Code Explanation: Movement Functions

forward() runs all four motors in the FORWARD direction, so the car drives straight ahead. backward() runs all four motors in BACKWARD. turnLeft() runs the left motors (M1, M2) backward and the right motors (M3, M4) forward, creating a tank-style left turn. turnRight() does the opposite: left motors forward, right motors backward. stop() calls RELEASE on all motors, which cuts power and lets the car coast to a halt.

How to Change Speed

The motor speed is set in setup() using motor1.setSpeed(255). The value ranges from 0 (stopped) to 255 (full speed). To slow the car down, reduce this value. For example, 150 gives roughly 60% speed. You can also set different speeds for turning versus straight driving by calling setSpeed() inside the movement functions.

How to Test the Code Safely

For your first test, prop the car up so the wheels do not touch the ground (use a box or a stack of books). This way you can verify each direction without the car driving off the table. Connect via Bluetooth, send each command from the app, and confirm all four wheels spin in the expected direction. Once verified, set the car on the floor and test at low speed by reducing setSpeed() to around 120.

الخطوة 7: تطوير تطبيق أندرويد للتحكم عبر البلوتوث

We will use MIT App Inventor to create a simple Android app that connects to the HC-05 module over Bluetooth and sends directional commands to the Arduino. MIT App Inventor is a free, browser-based visual programming tool, ideal for beginners who want to build an HC-05 robot car app without writing Java or Kotlin code. To understand the basics of Arduino programming that the app communicates with, refer to our أساسيات برمجة أردوينو مرشد.

Register and Create a Project

  • Go to MIT App Inventor (ai2.appinventor.mit.edu) and log in with your Google account.
  • Click “Start New Project” and name it “RobotCarControl”.

Design the User Interface

In the Designer view, add the following components to your app screen:

  • ListPicker – Set its text to “Select Bluetooth Device”. This lets the user choose which paired Bluetooth device to connect to.
  • Label (Label1) – Add a Label component to display the connection status. The blocks will set this label to “Connected” or “Not Connected” depending on the Bluetooth connection result. This label is referenced as Label1 in the block code below, so make sure you add it to your interface.
  • BluetoothClient – Drag this from the Connectivity palette. It is a non-visible component that handles Bluetooth communication.
  • Four Buttons – Add buttons named ButtonForward, ButtonBackward, ButtonLeft, and ButtonRight. Set their text and colors to clearly indicate directions.

Program the Blocks

Switch to the Blocks view and add the following logic. These blocks handle Bluetooth device selection, connection, and sending movement commands when buttons are pressed and released.

عند النقر على ListPicker1.BeforePicking، قم بتعيين ListPicker1.Elements إلى BluetoothClient1.AddressesAndNames. عند النقر على ListPicker1.AfterPicking، إذا تم استدعاء BluetoothClient1.Connect address ListPicker1.Selection، فقم بتعيين Label1.Text إلى "متصل". وإلا، فقم بتعيين Label1.Text إلى "غير متصل". عند الضغط على ButtonForward.TouchDown، إذا كان BluetoothClient1.IsConnected، قم باستدعاء BluetoothClient1.SendText نص "F". عند الضغط على ButtonBackward.TouchDown، إذا كان BluetoothClient1.IsConnected، قم باستدعاء BluetoothClient1.SendText نص "B". عند الضغط على ButtonLeft.TouchDown، إذا كان BluetoothClient1.IsConnected، قم باستدعاء BluetoothClient1.SendText نص "L". عند الضغط على ButtonRight.TouchDown، إذا كان BluetoothClient1.IsConnected، قم باستدعاء BluetoothClient1.SendText نص "R". عند رفع زر ButtonForward.TouchUp، إذا إذا كان BluetoothClient1.IsConnected متصلاً، فقم باستدعاء BluetoothClient1.SendText لإرسال النص "S" عند الضغط على زر الرجوع للخلف. إذا كان BluetoothClient1.IsConnected متصلاً، فقم باستدعاء BluetoothClient1.SendText لإرسال النص "S" عند الضغط على زر اليسار. إذا كان BluetoothClient1.IsConnected متصلاً، فقم باستدعاء BluetoothClient1.SendText لإرسال النص "S" عند الضغط على زر اليمين. إذا كان BluetoothClient1.IsConnected متصلاً، فقم باستدعاء BluetoothClient1.SendText لإرسال النص "S""
    
MIT App Inventor blocks editor screenshot showing the Bluetooth connection logic, ListPicker event handlers, and TouchDown/TouchUp blocks for the four directional buttons that send F, B, L, R, and S commands
MIT App Inventor blocks: Bluetooth connection handling and directional button commands for the robot car control app

Understanding the Block Logic

ListPicker.BeforePicking: When the user taps the ListPicker, it populates the list with all paired Bluetooth device addresses and names from BluetoothClient1.AddressesAndNames.

ListPicker.AfterPicking: After the user selects a device, the app attempts to connect using BluetoothClient1.Connect with the selected address. If successful, Label1.Text is set to “Connected”; otherwise, it shows “Not Connected”. This is why the Label1 component must be present in your interface.

TouchDown events: When the user presses (touches down on) a directional button, the app sends the corresponding command character (F, B, L, or R) via BluetoothClient1.SendText, but only if the Bluetooth connection is active.

TouchUp events: When the user releases (lifts their finger from) any directional button, the app sends “S” (stop). This design means the robot moves only while you hold a button and stops immediately when you release it, giving you precise real-time control.

الخطوة 8: توصيل الروبوت واختباره

With the hardware assembled, the code uploaded, and the app installed on your phone, it is time to bring everything together.

Pair the HC-05

Turn on Bluetooth on your Android smartphone and go to Bluetooth settings. Search for new devices. The HC-05 will appear as “HC-05” in the list. Pair with it using the default PIN code 1234 (or 0000 on some modules). You only need to pair once; the phone will remember the device.

Connect and Drive

Open the RobotCarControl app on your phone. Tap the “Select Bluetooth Device” ListPicker and choose the HC-05 from the list. The Label1 should display “Connected”. Now press the directional buttons to drive the car. The robot should move forward, backward, turn left, turn right, and stop when you release the buttons.

How to Test and Tune the Robot Car

Getting the robot car to drive perfectly often requires a bit of tuning after the initial build. Here are practical steps to dial in the performance of your Arduino Bluetooth car.

  • Test one direction at a time. Start by sending only the F command and confirming all four wheels spin forward. Then test B, L, and R individually.
  • Verify left/right motor orientation. If the car veers to one side during forward driving, one motor pair may be wired in reverse. Swap the two wires at the affected motor terminal on the shield.
  • Reduce speed during first tests. تعيين setSpeed(120) instead of 255. This gives you more reaction time and prevents crashes during indoor testing.
  • Fix wrong turning direction. If “Left” turns the car right, swap the left and right motor assignments in the code (change M1/M2 logic to M3/M4 and vice versa), or physically swap the motor wiring.
  • Improve responsiveness. If the car feels sluggish or delayed, check that the HC-05 baud rate matches the Arduino serial baud rate (9600). Also ensure fresh batteries, as low voltage causes slow motor response.

استكشاف الأخطاء وإصلاحها في المشاكل الشائعة

If your Bluetooth controlled robot car is not working as expected, check the common issues below before starting over. Most problems are caused by simple wiring mistakes or configuration mismatches.

HC-05 Pairs but the Car Does Not Move

The Bluetooth connection is established, but the motors do not respond. Check that the HC-05 TXD pin is connected to Arduino RX (pin 0) and RXD to Arduino TX (pin 1). Also verify that the baud rate in your Arduino code matches the HC-05 default (9600). Make sure the motor shield is properly seated on the Arduino and that the battery pack is connected and turned on.

Arduino Upload Fails (RX/TX Conflict)

If you get upload errors like “avrdude: stk500_getsync(): not in sync”, the HC-05 is likely still connected to pins 0 and 1. Disconnect the HC-05 RX and TX wires, upload the sketch, then reconnect them. This is the most common issue when using hardware serial with a Bluetooth module.

Robot Moves in the Wrong Direction

If forward drives the car backward, swap the two wires for all four motors at the motor shield terminals. If the car turns opposite to the expected direction, swap the left-side and right-side motor connections or adjust the code.

One Side of the Car Does Not Move

Check the wiring on the non-working side. Make sure the motor wires are firmly inserted into the screw terminals and that the terminal screws are tight. Test the motors individually by running only motor1 or motor3 in the code. If a terminal on the shield is damaged, try using a different M-terminal.

App Connects but Buttons Do Nothing

Verify that the app is sending the correct characters (F, B, L, R, S). In MIT App Inventor, make sure the BluetoothClient component is properly linked in the blocks and that SendText uses the exact uppercase characters expected by the Arduino code. Also confirm that Label1 shows “Connected” after pairing.

Motors Are Weak or Inconsistent

Weak motors usually indicate a power problem. Replace the batteries with fresh ones or switch to a higher-capacity battery pack. Four DC motors under load draw significant current, and depleted batteries cannot deliver enough. Also check all power connections for loose wires.

Robot Keeps Moving After Button Release

This means the stop command (S) is not being sent or received when you lift your finger. In the app, make sure every button has both a TouchDown block (to send the movement command) and a TouchUp block (to send “S”). If the TouchUp blocks are missing, the Arduino never receives the stop command.

Battery Power Is Insufficient

If the Arduino resets when motors start or the car behaves erratically, the battery pack cannot supply enough current. Use a pack rated for at least 2A continuous output. Rechargeable NiMH AA batteries or a 2S Li-ion pack with a BMS work well for four-motor robot cars.

الأسئلة الشائعة

هل يمكنني استخدام وحدة HC-06 بدلاً من وحدة HC-05؟

Yes. The HC-06 works as a slave-only Bluetooth module, which is exactly what this project needs. The wiring and baud rate are the same. The only difference is that the HC-06 cannot initiate connections, but since the phone always initiates, this does not matter. See our HC-05 vs. HC-06 comparison for details.

What Bluetooth app can I use to control the robot car?

This tutorial uses a custom app built with MIT App Inventor, which gives you full control over the interface and command mapping. Alternatively, you can use generic Bluetooth serial terminal apps from the Google Play Store, but you will need to type the command characters (F, B, L, R, S) manually instead of pressing buttons.

Can I control the robot car from an iPhone?

Not directly. The HC-05 uses Bluetooth Classic (SPP), which iOS does not support for third-party apps. To control the car from an iPhone, you would need to replace the HC-05 with a BLE (Bluetooth Low Energy) module like the HM-10 or use an ESP32 with BLE support, and modify the app accordingly.

Why does my Arduino reset when the motors start?

This is almost always a power issue. When all four motors start simultaneously, the current spike can cause the supply voltage to drop below the Arduino minimum, triggering a reset. Use a battery pack with higher current capacity, and make sure the motor power and Arduino power share a common ground but ideally come from a source that can handle the load.

Can I use the Adafruit Motor Shield V2 instead of V1?

Yes, but the code library is different. The V2 shield uses the Adafruit_MotorShield library (I2C-based) instead of AFMotor.h. The wiring and motor terminal layout are similar, but you will need to rewrite the motor initialization and control portions of the code to use the V2 library API.

How far can the Bluetooth connection reach?

The HC-05 has a typical range of about 10 meters (30 feet) in open air. Walls, interference from Wi-Fi routers, and other Bluetooth devices can reduce this range. For most indoor robot car projects, 10 meters is more than enough.

How do I add speed control from the app?

You can add a slider in MIT App Inventor that sends a speed value (for example, 0 to 255) as a separate command. In the Arduino code, read this value and call motorX.setSpeed(value) for all four motors. Use a different command prefix (like “V” followed by the number) to distinguish speed commands from direction commands.

Can I use this project with two motors instead of four?

Yes. For a two-wheel-drive car, connect the two motors to M1 and M3 (or any two terminals, one per side). Remove the unused motor objects from the code or simply leave them defined but unconnected. The turning and driving logic remains the same.

Why does the car only turn in circles?

If the car turns in circles during a forward command, one side of the motors is wired in the reverse direction. Swap the two wires for the motors on the side that is spinning the wrong way at the shield screw terminals.

Do I need to install a special library for the code?

Yes. You need the Adafruit Motor Shield library (AFMotor.h). In the Arduino IDE, go to Sketch > Include Library > Manage Libraries, search for “Adafruit Motor Shield library”, and install it. This library is required for the AF_DCMotor class used in the code.

الموارد والمشاريع القادمة

Now that you have built your first Bluetooth controlled robot car with Arduino, here are related OmArTronics tutorials to continue learning and building more advanced projects:

For further upgrades, consider adding obstacle avoidance with an ultrasonic sensor, a camera module for FPV driving, or switching to an ESP32 for Wi-Fi-based control and longer range.

خاتمة

In this tutorial, you built a complete Bluetooth-controlled robot car with Arduino, HC-05, and Adafruit Motor Shield from the ground up. You assembled a four-wheel-drive chassis, wired four DC motors through the Adafruit Motor Shield, connected the HC-05 for wireless Bluetooth communication, wrote Arduino code to interpret movement commands, and created a custom Android control app with MIT App Inventor.

This project gives you a solid foundation in motor control, wireless communication, and mobile app development, which are core skills for any robotics enthusiast. From here, you can expand the car with autonomous obstacle avoidance, add speed control via the app, or upgrade to a more powerful Arduino Mega platform with additional sensors. Check out the advanced autonomous robot car tutorial أو obstacle-avoiding robot car project for your next build. Happy building!

Feel free to ask any questions in the comments section below and explore our other Arduino tutorials for more project inspiration.

رأي واحد حول “Building a Bluetooth-Controlled Robot Car with Arduino, HC-05, and Adafruit Motor Shield”

أضف تعليق