close
no thumb

Overview

Bluetooth is a wireless technology capable of transmitting and receiving data over short distances. This technological platform is utilized on mobile phones, laptops, and other devices. This project uses Bluetooth to control a robot car.

In this project, the AlphaBot 2-Ar is controlled by an Android application. This mobile robot development platform can be programmed using the Arduino Uno.

Hardware Used

Software Used

  • Arduino IDE
  • Android GamePad Application – click to download

Libraries Used

  • SoftwareSerial.h

Application Description

This project uses Bluetooth to control a mobile robot platform. The robot moves forward, backward, left, or right. Also, there is a button which halts the robot when running. Lastly, the robot’s speed can be modified using the three buttons of the gamepad. The three buttons are designated as low speed, medium speed, or high speed.

Set-up The Hardware

AlphaBot Schematics

The AlphaBot 2-Ar contains two major parts. These are the chassis and the adapter board.

The parts contained on the chassis are shown below.

  1. Ultrasonic module interface
  2. AlphaBot2 control interface: for connecting sorts of controller adapter board
  3. Obstacle avoiding indicators
  4. Omni-direction wheel
  5. ST188: reflective infrared photoelectric sensor, for obstacle avoiding
  6. ITR20001/T: reflective infrared photoelectric sensor, for line tracking
  7. Potentiometer for adjusting obstacle avoiding range
  8. TB6612FNG dual H-bridge motor driver
  9. LM393 voltage comparator
  10. N20 micro gear motor reduction rate 1:30, 6V/600RPM
  11. Rubber wheels diameter 42mm, width 19mm
  12. Power switch
  13. Battery holder: supports 14500 batteries
  14. WS2812B: true color RGB LEDs
  15. Power indicator

On the other hand, the parts on the AlphaBot adapter board are shown below.

  1. AlphaBot2 control interface: for connecting AlphaBot2-Base
  2. Arduino expansion header: for connecting Arduino shields
  3. Arduino interface: for connecting Arduino compatible controller
  4. Xbee connector: for connecting dual-mode Bluetooth module, remotely control the robot via Bluetooth
  5. IR receiver
  6. PC8574: I/O expander, SPI interface
  7. Arduino peripheral jumpers
  8. TLC1543: 10-bit AD acquisition chip
  9. Buzzer
  10. 0.96inch OLED SSD1306 driver, 128×64 resolution
  11. Joystick

HC-05 Assembly Diagram

The image shown above is the connections for the HC-05 Bluetooth module. The VCC and GND pins of the module are connected to the VCC and GND pins of the Arduino Uno.

Furthermore, the TX pin of the HC-05 module is connected to the pin 2 of the Arduino. Also, there is a resistor configuration in this schematic diagram. The resistors in series form a voltage-divider circuit, wherein the 5 volts from the Arduino is divided into three equal parts. The circuit was created since the RX pin of the HC-05 Bluetooth module can handle 3.3 volts only. Establishing 5 volts into the RX pin of the Bluetooth module puts it at risk of damage.

Set-up The Software

Code Breakdown

The snippet shown above is the code needed for this project. The code is divided into three major parts. These are the initialization of variables, the setup function, and the loop function. Each part will be explained thoroughly below.

The first major part of the code is the initialization of variables. This is where the variables used in the code is first given a value and/or a data type. Also, this is where the library SoftwareSerial is included in the code. The SoftwareSerial library is used to incorporate serial communication onto the different pins of the Arduino Uno rather than using pins 0 and 1 for serial communication. Serial communication is a type of communication wherein data is transmitted and received using a communication channel one bit at a time.

To use the different pins of the Arduino Uno as the RX and TX pins of the serial communication, the Arduino pins must be declared. The second line of the code shown above states pins 2 and 7 as the RX and TX pins, respectively.

Furthermore, the pins for the different motors of the AlphaBot are defined. These pins are used to control the different motors of the mobile robot. This allows the robot to move in any direction and change to different speeds, depending on the program,

The second major part of the code is the setup function. This is where the different Arduino pins needed are assigned as either inputs or outputs. Also, this is where the baud rate is defined in both the hardware and software serial communication. Baud rate is defined as the rate of transfer of information in a communication channel. In this project, a baud rate of 9600 is used. This means that the serial port is capable of sending and receiving a maximum of 9600 bits per second.

The third and final major part of the code is the loop function. This is where the Arduino does its processes and repeats it continuously. The first section of the loop function is the acquisition of data from the mobile app. In this section, the Arduino reads the string that was sent by the mobile app.

After reading the string, a system of if-else statements was used to compare the string to different parameters. Once the string and the given parameter are equal, the Arduino performs the function. This concept is very familiar to programming, as it uses if-else statements to execute different lines of code for every situation.

Android Application

There are different Android applications found on the Google Play Store which allows its users to control different modules and kits using Bluetooth. The download link for the Android application was shown in the earlier parts of this tutorial.

After installing the application from the Play Store, launch the app. Once launched, a pop-up will appear and asks to allow itself to turn on Bluetooth. Click Yes to allow.

After allowing the app to turn on Bluetooth, a list appears containing different available Bluetooth devices. In this project, the HC-05 Bluetooth module was utilized.

Next, a pop-up appears when the HC-05 was chosen as the Bluetooth module to connect to. Since the project aims to control the mobile robot platform via Bluetooth, click Controller mode.

A gamepad screen appears after selecting controller mode. To activate this gamepad, click the gear button at the right-hand side.

 

 

 

 

 

 

 

 

 

 

 

 

The Settings tab of the gamepad displays its buttons and its corresponding strings. These strings are what the Bluetooth module receives from the application. It was explained earlier that the Arduino uses if-else statements to compare the acquired string and the different parameters of the if-else statements.

Robot Control

The image shown above is the controls for the robot car. It is imperative to know that the robot car moves until the brake button is pressed, as shown in the featured image. The speed of the robot can be changed through the three buttons shown above. The user may change the speed allotted for low, medium, and high speeds in the code.

References

Tags : alphabotandroidandroid phonearduinobluetoothcargamegamepadHC-05padrobotrobot carrobot car kitsoftwaressoftwareserial

Leave a Response