Arduino Bluetooth Controlled Multi-modal Robotic Car (Android and iOS Compatible)

From ArduinoInfo
Revision as of 07:26, 26 September 2019 by Kufy (talk | contribs)

Jump to: navigation, search


The Arduino micro-controller is capable of running only one sketch at a time. Therefore, it is generally thought that the Arduino can only perform one task or achieve one objective per-sketch. This project shows the implementation of a multi-modal bluetooth controlled robotic car, capable of achieving different tasks and objectives, and is controlled with an Android or iOS mobile application. Everything happens in real-time, with little to no delay.


The communication with the robot is made possible via Serial-over-Bluetooth protocol. A bluetooth module is connected to the Arduino compatible board, and the mobile phone which the application has been installed on can connect to the bluetooth module.

This robot has been built to have 5 modes:

  1. Line-follower Mode
  2. Object-follower Mode
  3. Light-follower Mode
  4. Ramble Mode
  5. Manual-control Mode

Hardware Components

  1. HM10 Bluetooth Module x 1
  2. Yourduino RoboRed Board x 1
  3. MOTOR DRIVER (? Which version?)
  4. Line Tracker Sensor x 1
  5. Photo-resistor x 1
  6. Buzzer x 1
  7. Ultrasonic sensor x 1
  8. Motor driver x 1
  9. Geared DC motors x 2
  10. Micro servo motor kit x 1
  11. Robot car chassis with 2 wheels x 1

Configuring the HM10 BLE 4 Module

The HM10 module was chosen for this project due to it's compatibility with the common BLE 4.0 (Bluetooth Low Energy) protocol, used on Apple Iphones as well as Android phones. Before the module can be used, the baudrate, device name, and preferred pin have to be set. Below are steps for setting up the HM10 Module using the RoboRED board:

  1. The schematic of Arduino shows that the RX and TX pins are connected to the USB Interface chip (on Arduino board as pin 0 and pin 1), which means that those pins can directly access the USB Interface chip itself. We generally use TX and RX pins for communication. Upload the empty sketch below to the RoboRED board in order to enable it serve as USB-TTL converter for communicating with the HM10 module:
    void setup() {
    void loop() {
  2. Disconnect the Arduino USB connection
  3. Connect HM10-Tx --> RoboRED-Tx(Pin1) and HM10-Rx --> RoboRED-Rx(Pin0) (i.e. Tx --> Tx and Rx --> Rx of each board), then HM10-Vcc --> RoboRED-5V line (any of the pins with a red base) on the RoboRED and HM10-GND --> RoboRED-GND (any of the pins with a blue base)
  4. Plug in the RoboRED's USB to the PC and open the Arduino IDE
  5. Open the Serial Monitor and set the baudrate to 9600
  6. Type AT and press enter. If the response is OK, then the module is ready to be configured using AT commands
  7. Type AT+VERR? command to check the firmware version that runs on your HM10 module. V5** and above is good
  8. Type AT+NAME? to see current name of the module, otherwise, type AT+NAMEpreferredName to set a preferred Bluetooth name for the module. Kindly note that there should be NO space between the AT+NAME and the preferredName chosen
  9. Next, set the passcode that would be required for connecting to the module; AT+PASSpreferredPasscode. The preferred passcode must be 6 numbers. To check the passcode, use AT+PASS?
  10. The HM10 module is configured to connect without passcode (i.e. AT+TYPE0). Set it to request a passcode on pairing by using this command: AT+TYPE2

The module is now configured and ready to be used. To save your settings, use AT+RESET in other to save and reset the module

Setting up the Motor and Motor Driver

In order to get the desired functionality of the motors and motor drivers, it is necessary to know what pins of the motor drivers control what direction. This is a tricky, but easy process and the steps are outlined:

  • First, start with one motor (Motor A). Connect pin A-1A of the L9110 motor driver (or IN1 of L293N motor driver) to MA_dir pin on the Arduino and pin A-1B of the L9110 motor driver (or IN2 of L293N motor driver) to MA_spd pin on the Arduino which we have defined in the code
    const byte MA_dir = 4;  // Motor Control Pins Direction and PWM Speed
    const byte MB_dir = 7;
    const byte MA_spd = 5;
    const byte MB_spd = 6;
    void setup()   /**************************** SETUP: RUNS ONCE *******************/
      pinMode(MA_dir, OUTPUT);
      pinMode(MB_dir, OUTPUT);
      pinMode(MA_spd, OUTPUT);
      pinMode(MB_spd, OUTPUT);
    }//--(end setup )---
    void loop()   /******************** LOOP: RUNS CONSTANTLY *******************/
    void front()
      digitalWrite(MA_dir, HIGH);
      digitalWrite(MB_dir, HIGH);
      analogWrite(MA_spd, 0);
      analogWrite(MB_spd, 80);
  • If Motor A moves in the desired front direction (i.e. in a clockwise direction if the front of the motor wheel is facing you), then motor one is all set; else, interchange the red and black wires of the motor that go into Motor A slots of the motor driver
  • To configure Motor B, Connect pin B-1A of the L9110 motor driver (or IN3 of L293N motor driver) to MB_dir pin on the Arduino and pin B-1B of the L9110 motor driver (or IN4 of L293N motor driver) to MB_spd pin on the Arduino which we have defined in the code. If Motor B moves in the desired front direction (i.e. in an anti-clockwise direction if the front of the motor wheel is facing you), then motor one is all set; else, interchange the red and black wires of the motor that go into Motor B slots of the motor driver

Setting up the Servo

Using the Mobile Application

In order to control the robot car, a Mobile App has been designed with bluetooth capabilities to be able able to interface with the car via its HM10 BLE 4.0 module. BLE 4.0 protocol was chosen as it is compatible with both Android and iOS devices, and it consumes low energy.