Blank Line Following Robot using 8051 MUC

This a lab tested code of Blank line following robot using 8051 MUC. When there is black below an IR sensor, its output is binary-1. When there is white below an IR sensor, its output is binary-0. This code is suitable for OVAL SHAPED SIMPLE BLACK TRACKS. For complicated black tracks USE POWER TURN INSTEAD OF SOFT TURN.

The following code is given as per the kit developed at Vidyasagar Academy. To purchase the kit, contact us. If you are the student of Vidyasagar Academy burn the code in the given kit.

Check following diagrams for using our kit.

Useful Diagrams

The Code

/*
  	Program of Black line following robot
	Created by: VIDYASAGAR ACADEMY, http://localhost/wordpress/
	Date: 26.04.2017
	*** Please respect our efforts and write Google review about Vidyasagar Academy, Akola. ***
*/

#include <reg51.h> // including header file
#include "delay.c"
#define motors P1 // PORT1 is assigned to "motors"
sbit LS=P3^7; // left IR sensor is connected to pin-7 of PORT3
sbit RS=P3^0; // right IR sensor is connected to pin-0 of PORT3
	
	int main() // main function
	{ // opening brace of main function
	delay(5000);

	while(1) // infinite loop
	{ // opening brace of while loop


	if((LS==0)&(RS==0)) // both sensors are on white
	{
	motors=0x09; // forward
	}

	if((LS==1)&(RS==1)) // both sensors are on black OR robot is lifted up
	{
	motors=0x00; // stop
	}

	if((LS==1)&(RS==0)) // only LS is on black
	{
	motors=0x01; // soft left turn (***** Refer above note)
	}

	if((LS==0)&(RS==1)) // only RS is on black
	{
	motors=0x08; // soft right turn (***** Refer above note)
	}

	} // while closed
	} // main function closed

Note: Download the file of delay.c mentioned in the above program, from following link and copy it in your project folder.

[page_download category=”3″]

Share on your network!
Dattaraj Vidyasagar
Dattaraj Vidyasagar

Author on this website. He is veteran of Core Electronics since last 36+ years. ATL Mentor of Change, Niti Ayog, Govt. of India, Google Certified Educator, International Robotics Trainer and author of 18 books on electronics, robotics, programming languages and web designing... ➤➤

Leave a Reply

Your email address will not be published. Required fields are marked *