Line Tracking Module interfacing with pic microcontroller

In this line tracking module tutorial, you will learn what is line tracking module? Are you planning to make a line follower robot and you do not have time to make your own sensors module? You can use these tracking modules. How to use it for making a line follower robot?  You may also like to check our project line follower robot using a microcontroller.  If you are considering making an obstacle avoidance robot, you can check the following article:

What is Line Tracking Module?

The line tracking module is the type of infrared sensor module, which consists of two infrared sensors such as an infrared transmitter and an infrared receiver. It has almost the same working principle and construction as well as with infrared obstacles avoidance sensor module, but the only difference is that it has low transmitting power. This line tacking module has the property to detect a black line in white color and white line in black color.  It provides a more stable and accurate output. These are easy to use and are easily available in the market or online shop. These are mostly used in the robotic industry as well as in those things in which infrared technology plays an important role such as scanner and door opening switches etc. A simple single channel line tracking module is shown in figure 1Line Tracking Module

Figure 1 Single Channel Line Tracking Module

Check this line>> follower robot project using microcontroller

Pin Configuration of Line Tracking Module

Every line tracking module consists of three pins such as VCC, GND and signal pin. For power on this line tracking module, positive voltages are applied at VCC pin and negative or ground voltages are applied at its ground pin. It is powered up with dc voltages within the range of 3.3V to 5V. Similarly, its third pin which is basically its output pin, output voltages or signal is received from this pin. Any type controller such as Arduino or microcontroller etc. could be installed with this line tracking module for attaining the output voltages or signal. Beside this, it also consists of two infrared LEDs, one potentiometer and one power LED.

In these infrared LEDs, first, one is used such as an infrared transmitter for transmitting the infrared signal and the second one is used such as an infrared receiver for receiving the infrared signal. The potentiometer is used for adjusting the distance or range of this line tacking module. By increasing or decreasing the resistance of this potentiometer, the sensing area of this line tracking module could be adjusted. It is very easy to adjust with the help of any knob or screwdriver. Similarly, the power LED which is turned on when the module is turned on and turned off when the module is turned off.

Working Principle of Line Tracking Module

The working principle of the line tracking module is very simple, it is almost the same as obstacles avoidance tracking module, but it has a low power transmitter. Because it consists of an infrared transmitter which sends the infrared signal in its respective area. When an object such as paper or line is present in this respective area then this paper, line or object block this signal then it is reflected back toward the infrared receiver.

On the basis of this reflected signal, the resistance of this tracking module is changed which is inversely proportional to output signal voltages. Means, when resistance is increased then output voltages are decreased, similarly when it is decreased then output voltages are increased. Because the output of this module is connected with any controller, therefore, these voltages are received by the controller and on the basis of these voltages, the controller decided what is object or thing, where is object and how much distance where it is placed.

How to Interface Line Tracking Module with PIC16f877a Microcontroller?

Line Tracking Module interfacing with pic microcontrollerAs we discussed in the above paragraph a controller is required for using this line tracking module in any application. For these purposes, we can use microcontroller or Arduino etc. But here we shell only interface this line tracking module with pic microcontroller. Every microcontroller consists of fore ports and any port could be used as input or output port. It is programmed in c language with the help of mikro/c software and is powered up with 5V dc voltages.

When the output voltages of this line tracking module are connected with any port of microcontroller then microcontroller received this output voltage. On the biases of these voltages and program, which is inserted in this microcontroller through software, the microcontroller decided where is line or paper and angular position of presence object. If it is used in line following robot then it turns on or off the robot according to the line. The line is basically the actual path of this line following robot.

Code of line tracking module interfacing with pic microcontroller

Code for line tracking module interfacing with pic microcontroller is given below. The code is written using Mikro c for pic. if you are just getting started with pic microcontroller programming, you can check this getting started tutorial:

// line tracking module connected with pin number TRISD.B0
// Buzzer module conneced with pin number zero of PORTE
void main(void)
{

TRISD.B0=1; // PIN NUMBER 1 IS DECLARED AS A INPUT
PORTE.B0=0;
TRISE.B0=0; // PIN NUMBER 1 IS DECLARED AS A OUTPUT
while(1)
{ 

if( PORTD.B0==1)
{
PORTE.B0=1; // it will make buzzer on
}
else
{
PORTE.B0=0; // it will make buzzer off
}
}
}
  • In this code, first, we initialized the one GPIO pin as a digital input pin and one GPIO pin as a digital output pin.
  • Digital input pin is used for line tracking module which is used to read the state of line tracking module.
  • The digital output pin is used to control the buzzer.  you can check this buzzer module interfacing with pic microcontroller tutorial also.
  • Inside the main function, while loop is an endless loop which will keep executing commands inside it.
  • Inside the while loop, if else condition checks either the output of the line follower module is digital HIGH or digital LOW.
  • If the output is HIGH, it will turn on the buzzer and otherwise, buzzer remains off.

you may like to check other sensor related pic microcontroller projects:

Leave a Comment