You are on page 1of 3

Major Project

Line Follower Robot using 8051 Microcontroller


- Haneeth
ESP-07-BSP1

A line follower robot is a mobile machine that can detect and follow the line drawn on the floor. Generally, the path is
predefined and can be either visible like a black line on a white surface with a high contrasting colour or it can be invisible
like a magnetic field.
Components required:

● 8051 Microcontroller

● L293D Motor Driver

● IR Sensors (2)

● Motors (2)

● 11.0592MHz Crystal

● 33pF Capacitor (2)

● 10µF Capacitor

● Push Button

● 10KΩ Resistor (2)

● 12V Battery

● 5V DC Power source

Code:

#include<reg51.h>
sbit s1=P1^0;
sbit s2=P1^1;

sbit motor_pin_1 = P3^0; // connect motor pins to port 3


sbit motor_pin_2 = P3^1;
sbit motor_pin_3 = P3^2;
sbit motor_pin_4 = P3^3;
void main()
{
motor_pin_1=0;
motor_pin_2=0;
motor_pin_3=0;
motor_pin_4=0;

while(1) //infinte loop


{
if((s1==1)&(s2==1)) //check sensor is high or not
{
// forward function
motor_pin_1 = 1;
motor_pin_2 = 0;
motor_pin_3 = 1;
motor_pin_4 = 0;
}
else if((s1==0)&(s2==1))
{
motor_pin_1 = 1;
motor_pin_2 = 0;
motor_pin_3 = 0;
motor_pin_4 = 0;
}

else if((s1==1)&(s2==0))
{
motor_pin_1 = 0;
motor_pin_2 = 0;
motor_pin_3 = 1;
motor_pin_4 = 0;
}

else if((s1==0)&(s2==0))
{
motor_pin_1 = 0;
motor_pin_2 = 0;
motor_pin_3 = 0;
motor_pin_4 = 0;
}
}
}

You might also like