Maker.io main logo

Line Following Robot with Android and Arduino

2016-08-02 | By Aron Bordin

License: General Public License Arduino

Project Timotheo is an autonomous line following robot powered by an Arduino Uno with Bluetooth and an Android device.

How This Project Works

In detail, the project is divided into two modules: Arduino and Android.

1.    Arduino - Arduino has a simple communication layer. When Arduino receives a new message via Bluetooth, the message is analyzed and an action is executed. This action can be something related to movement (turn right, stop, etc.) or something related to sensors. Only an abstract code will be uploaded to the Arduino with nothing related to robot logic. This enables the robot to do anything, without re-coding it.

2.    Android - All the robot logic lives here. Android will be constantly reading raw camera data to follow the line. Depending on the position of the line, Android will send commands to the connected Arduino.

Image Processing Explained

To identify a line, several steps need to be executed. Initially, a picture is taken. To detect the line, a 5X240 region of the picture is selected. The region is then divided into five blocks, and a median value of each block is calculated. The median value is compared to a variable to identify if the block is white or black. White and black are represented by 1 and 0, respectively. After analyzing the five blocks, there will be five values, creating an integer between 00000 and 11111, where 00000 is completely black and 11111 is completely white.

Coding

Simply put, the coding is separated into five sections: camera app, user interface, application logger, image processing, and calibration. These five coding segments are accomplished in proper succession in order to achieve the desired result.

Robot Schematics

There are only a few key components used in assembling the robot. These are as follows:

Keyes L298

Keyes L298

Ultrasonic Bluetooth HC-05

Ultrasonic Bluetooth HC-05

HC-SR04

HC-SR04

Communication Protocol

This protocol, although optional, can make the connection of any device to this robot using Bluetooth, radio, Wifi, etc a lot easier.

Arduino Code

A .PNG Arduino Framework was used to code the project leading to only less than 100 lines of codes. Using the communication protocol, this robot can be used in new products without having to edit the source code.

This project is nearing its completion. What remains to be accomplished is the coding of the Android app to send commands to the Arduino with Bluetooth. So stay tuned!

 

TechForum

Have questions or comments? Continue the conversation on TechForum, DigiKey's online community and technical resource.

Visit TechForum