Line Follower Robot using microcontroller

Line Follower Robot Circuit Diagram



Components in the circuit

  • 8051 Microcontroller
  • Development Board for 8051 Microcontroller (preferred)
  • 10KΩ Resistors X 2
  • 10µF Capacitor
  • 11.0592MHz Crystal
  • 33pF Capacitors X 2
  • Push Button
  • Motor driver Module (L298N)
  • Robot Chassis with Motors
  • IR Sensors x 2

How to Design a Line Following Robot?

 The circuit consists of 8051 microcontroller, IR Sensors (with IR transmitter and IR Receiver), L298N Motor Driver Module, Robot Chassis with 4 wheels and 4 motors, battery holder.
8051 microcontroller is the main component of the project. It is an 8 bit microcontroller with 32 programmable I/O pins. This has many peripheral features like programmable UART, two 8-bit timer/counter, two interrupts, external memory access etc.
 The DC motors of the robot are connected to the controller using a motor driver IC. As the output of the controller is maximum 5V with very small current, it cannot drive the motors. So, to amplify this voltage motor driver IC is used. L298N can drive motors up to 36v and can provide a drive current of 3A.
The driver IC has 15 pins and is usually available in multiwatt15 Package. These ICs are easily available in the market as Modules. The inputs to the Motor Driver Module are connected to PORT2 pins P2.0, P2.1, P2.2 and P2.3. 
The two IR sensors are connected to P2.6 and P2.7 pins of the microcontroller. Arrange the chassis and connect the four wheels of the robotic vehicle to the motors which are in turn connected to the microcontroller.

Design of IR Sensors

IR sensor circuit consists of mainly IR transmitter and IR receiver. IR transmitter is similar to an LED. Its operating voltage is around 1.4V. So to protect it, a 150Ω resistor is placed in series with it and is connected in forward biased. IR receiver is connected in reverse bias and a 10KΩ resistor is placed between VCC and the receiver. Output is taken between resistor and IR receiver.
Since this is an analog output, we can convert it to a digital HIGH and LOW with the help of a simple comparator IC like LM358, for example. The IR Sensor Module used in this project uses the same configuration and the circuit diagram is shown below.



Working of IR Sensors

The IR transmitter continuously transmits the IR rays. When IR transmitter is on the black surface these rays were absorbed by the surface and when it is on white surface these rays were reflected. The IR receiver has maximum resistance when no IR rays are received and voltage from VCC flows through the resistor. At the output pin, voltage is approximately 5V.
As the intensity IR rays received by the receiver increases, resistance value decreases and reverse break down occurs. Thus voltage through the resistor is grounded. So, at the output pin, it will produce 0V.



Line Following Robotic Vehicle Circuit Working

  1. Initially draw the path on a light colored surface with black color tape.
  2. Place the robot on the floor.
  3. Now power on the circuit.
  4. Robot moves in the specified path.
  5. When it moves out of path, sensors check it and automatically adjust the robot.


Code


#include<reg51.h>
sbit mot1=P2^0;
sbit mot2=P2^1;
sbit mot3=P2^2;
sbit mot4=P2^3;
sbit s_left=P2^6;
sbit s_right=P2^7;
void forward (void);
void backward (void);
void left (void);
void right (void);
void forward (void)
{
mot1=0;
mot2=1;
mot3=1;
mot4=0;
}
void backward (void)
{
mot1=0;
mot2=1;
mot3=0;
mot4=1;
}
void left (void)
{
mot1=0;
mot2=1;
mot3=0;
mot4=0;
}
void right (void)
{
mot1=0;
mot2=0;
mot3=1;
mot4=0;
}
void stop (void)
{
mot1=0;
mot2=0;
mot3=0;
mot4=0;
}
void main()
{
s_left=1;
s_right=1;
while(1)
{
if(s_left==0 && s_right==0)
{
forward();
}
else if(s_left==1 && s_right==1)
{
stop();
}
else if(s_left==0 && s_right==1)
{
left();
}
else if(s_left==1 && s_right==0)
{
right();
}
}
}