Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe

Line Follower Robot

By Gurmeet Singh February 20, 2014

 

Image showing DC motors attached on Line Follower Robot

Fig. 1: Image showing DC motors attached on Line Follower Robot

 Image showing IR Sensor Modules attached on Line Follower Robot

Fig. 2: Image showing IR Sensor Modules attached on Line Follower Robot

Image showing Castor Wheel attached on Line Follower Robot

Fig. 3: Image showing Castor Wheel attached on Line Follower Robot

REQUIREMENTS FOR LINE FOLLOWER ROBOT:

1. AT89S52 (8051 microcontroller by ATMEL Corp.)rd wheel for support)

2. L293D (16 pin IC)

3. 2 X DC geared motors

4. 2 X wheels

5. 2 X IR sensors (module)

6. 7805 voltage regulator

7. 7V-8V Lithium Ion battery

8. Castor (3 wheel for support

9. Chassis

DESCRIPTION:

Line follower robot is a bot which can follow a particular line. Its  a very good project to start with, for people who are interested in robotics and embedded systems.

In this case, it will follow a black line on a contrasting white background surface.

This bot comprises of a sensor section, driver section and a microcontroller to process the sensor values and correspondingly operate the motor driver section.

Sensor section consists of IR sensors (2 in this case)

Driver section involves the working of geared DC motors (via L293D IC)

There are basically two orientations for the IR sensors to work.

Image showing orientation of IR sensors on the IR module

Fig. 4: Image showing orientation of IR sensors on the IR module

In the above case the sensors lie inside the black line

Image showing orientation of IR sensors on the IR module

Fig. 5: 

In this case the sensors lie outside the black line

In both the cases these sensors will help the bot to follow the line. The difference will be in their coding part.

Working

Prototype of 8051 Microcontroller based Line Follower Robot

Fig. 6: Prototype of 8051 Microcontroller based Line Follower Robot

To study the working of IR sensors visit my previous article: automatic room lighting

Sensors provide high value (1) when on white surface and low value (0) when on black surface.

Now talking about L293D, this IC will provide the desired voltage for the motors to operate properly. For its working visit: Interfacing L293D with 8051

When we work with case 1, the bot will move forward only when both sensors return 0(they are on black surface), it will move left when IR1 returns 1(on white surface) and IR2 returns 0(on black surface), it will move right when IR1 returns 0(on black surface) and IR2 returns 1(on white surface) and finally when both the sensors return 1(on white surface) the bot will stop.

When we work with case 2, the bot will move forward only when both sensors return 1(they are on white surface), it will move left when IR1 returns 1(on white surface) and IR2 returns 0(on black surface), it will move right when IR1 returns 0(on black surface) and IR2 returns 1(on white surface) and finally when both the sensors return 0(on black surface) the bot will stop.

When it comes to battery, one should always opt for those batteries which are high in performance and cheap. I’ll suggest to use Li-ion(cell phone batteries) because they are cheap and rechargeable.

You can connect two Li-ion batteries in series to get a voltage of 8V sufficient enough for driving 2 DC geared motors properly for long time.

Warning:  Be careful while recharging the batteries as they may explode when not charged properly.

I’ll suggest you to use a 9V adapter to charge these kinds of batteries (when 2 batteries connected in series) for not more than 2 hours.

 

 

Project Source Code

###



#include<reg51.h> 
sbit SR=P1^7;                       ////right sensor
sbit SL=P1^6;                      ////left sensor
sbit MRp=P1^4;                    ////right motor +ive terminal
sbit MRn=P1^3;                   ////right motor -ive terminal
sbit MLp=P1^2;                     ////left motor +ive terminal  sbit MLn=P1^1;                    ////left motor -ive terminal
void main()
{ 
  SR=SL=1;
  MRp=MLp=MRn=MLn=0;
  while(1)
{
 if(SR==0 && SL==0)
 {
                MRp=1; MRn=0;               ////moving forward
                MLp=1; MLn=0;
 }
 if(SR==1 && SL==0)
 {            
                MRp=1; MRn=0;              ////moving left
                MLp=0; MLn=1;
 }
 if(SR==0 && SL==1)
 {            
                MRp=0; MRn=1;                    ////moving right
                MLp=1; MLn=0;
 }
 if(SR==1 && SL==1)
 {
                MRp=0; MRn=0;                  ////stop
                MLp=0; MLn=0;
 }
}
}




CODING: (case 2)

#include<reg51.h>
sbit SR=P1^7;                      ////right sensor
sbit SL=P1^6;                      ////left sensor
sbit MRp=P1^4;                  ////right motor +ive terminal
sbit MRn=P1^3;                   ////right motor -ive terminal
sbit MLp=P1^2;                     ////left motor +ive terminal  sbit MLn=P1^1;                     ////left motor -ive terminal
void main()
{ 
  SR=SL=1;
  MRp=MLp=MRn=MLn=0;
  while(1)
{
 if(SR==1 && SL==1)
 {
      MRp=1; MRn=0;                     ////moving forward
      MLp=1; MLn=0;
 }
 if(SR==1 && SL==0)
 {            
       MRp=1; MRn=0;                       ////moving left
       MLp=0; MLn=1;
 }
 if(SR==0 && SL==1)
 {            
           MRp=0; MRn=1;                      ////moving right
           MLp=1; MLn=0;
 }
 if(SR==0 && SL==0)
 {
                MRp=0; MRn=0;                  ////stop
                MLp=0; MLn=0;
 }
}
} 

###

 


Circuit Diagrams

Circuit-Diagram-8051-Microcontroller-Based-Line-Following-Robot

Project Video


Filed Under: Electronic Projects
Tagged With: 8051, at89s52, IR Sensor, line follower robot
 

Next Article

← Previous Article
Next Article →

Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

EE TECH TOOLBOX

“ee
Tech Toolbox: Internet of Things
Explore practical strategies for minimizing attack surfaces, managing memory efficiently, and securing firmware. Download now to ensure your IoT implementations remain secure, efficient, and future-ready.

EE Learning Center

EE Learning Center
“engineers
EXPAND YOUR KNOWLEDGE AND STAY CONNECTED
Get the latest info on technologies, tools and strategies for EE professionals.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


RSS EDABOARD.com Discussions

  • Voltage mode pushpull is a nonsense SMPS?
  • Input impedance matching network
  • High Side current sensing
  • The comparison of different Tcl script checkers
  • Reducing "shoot-through" in offline Full Bridge SMPS?

RSS Electro-Tech-Online.com Discussions

  • Is AI making embedded software developers more productive?
  • Back to the old BASIC days
  • Parts required for a personal project
  • PIC KIT 3 not able to program dsPIC
  • Failure of polypropylene motor-run capacitors

Featured – RPi Python Programming (27 Part)

  • RPi Python Programming 21: The SIM900A AT commands
  • RPi Python Programming 22: Calls & SMS using a SIM900A GSM-GPRS modem
  • RPi Python Programming 23: Interfacing a NEO-6MV2 GPS module with Raspberry Pi
  • RPi Python Programming 24: I2C explained
  • RPi Python Programming 25 – Synchronous serial communication in Raspberry Pi using I2C protocol
  • RPi Python Programming 26 – Interfacing ADXL345 accelerometer sensor with Raspberry Pi

Recent Articles

  • What is AWS IoT Core and when should you use it?
  • AC-DC power supply extends voltage range to 800 V DC
  • Infineon’s inductive sensor integrates coil system driver, signal conditioning circuits and DSP
  • Arm Cortex-M23 MCU delivers 87.5 µA/MHz active mode
  • STMicroelectronics releases automotive amplifiers with in-play open-load detection

EE ENGINEERING TRAINING DAYS

engineering

Submit a Guest Post

submit a guest post
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • Battery Power Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • EV Engineering
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • Subscribe to our newsletter
  • About Us
  • Contact Us
  • Advertise

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy

Search Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe