Vidyasagar Academy Wishes a Very Happy, Healthy & Prosperous Diwali to all our Students & Teachers!
This a lab tested code of White 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 WHITE TRACKS. For complicated white tracks i.e. having many steep turns, 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.
#include <reg51.h> // including header file
#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
/* ==== IMPORTANT NOTE =====
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 *****
*/
int main() // main function
{ // opening brace of main function
while(1) // infinite loop
{ // opening brace of while loop
if((LS==1)&(RS==1)) // both sensors are on black
{
motors=0x09; // forward
}
if((LS==0)&(RS==0)) // both sensors are on white
{
motors=0x00; // stop
}
if((LS==0)&(RS==1)) // only LS is on white
{
motors=0x01; // soft left turn (***** Refer above note)
}
if((LS==1)&(RS==0)) // only RS is on white
{
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.
[download id=”2″]