A line following robot (LFR) is a machine that follows a line, which may be a black line or a white line. The follower bot is beginner friendly and easy to understand and build. While line follower robots are popular and common to build with Arduino or other microcontrollers, let's try to build the same thing without a microcontroller and really understand the logic behind it's working and use basic electronics to design logic circuits. As the name suggests, the robot will basically follow a line, but more advanced versions can be built, for example, we can have the robot trace the line and find the short distance between the start and end points, or have the robot solve a maze of lines, etc. Let's try a simple basic line following robot here. The robot basically consists of a pair of infrared sensors to detect lines and two motors to control movement and orientation.

Components needed to build a line-following robot

IR LED, transmitter and receiver (2 pairs)

Resistors 100k, 220 ohm, 1k (2 each)


Preset (Variable Resistor) (10k) (2)

LM358 integrated circuit

L293D IC

BO Motors and Wheels (2)


performance board

electric wire


9V battery (with battery clip) (2)

Learn how line-following robots work

The line below is a simple logic work obtained by combining the work of the comparator circuit and the work of the L293D motor driver. The IR sensor provides the output to the LM358 comparator IC. The IC provides a high output when the IR LED detects an object in front of it (or in our case, white light). The comparator IC then provides a high output (VCC). This is used as an input signal to decide whether to drive the motor. Since each IR sensor is associated with each motor, we can make the motor run forward by driving two motors, and we can turn it by driving only one motor at a time.

Learn how infrared sensors work

Infrared sensors are the reason the robot is able to follow the route. You can also use an IR sensor module, but we built an IR sensor here. Building an IR sensor is simple once you understand how it works. An infrared sensor basically consists of an infrared transmitter (IR LED) and an infrared receiver (photodiode). Sometimes IR LEDs and photodiodes together are called OptoCoupler or PhotoCoupler. As the name suggests, the IR Emitter LED emits infrared light. There are different types of infrared emitters based on wavelength, output power and response time. Similarly, there are a variety of IR receivers based on wavelength, voltage, packaging, and other factors. When used in an infrared transmitter-receiver combination, the wavelength of the receiver should match the wavelength of the transmitter.

When an IR LED emits infrared light, if there is an object blocking the infrared light, the surface of the object will reflect the infrared light, and the infrared photodiode is sensitive to these lights. The IR photodiode receives these reflected IR rays, so the resistance and output voltage change accordingly. Using this change in the output voltage (or the resistance of the photodiode), we can build logic circuits. This is how the IR sensor basically works; we'll use it to detect the presence of a wire. Now, when a white surface is present but a black surface will absorb, infrared is reflected. So we will be able to detect where the black line exists and we can build a logic circuit to follow this line. The working principle of the infrared transmitter and receiver is shown in the figure.

(Tip: To check if the IR emitter is emitting, use a camera (a phone camera will work too) to look at the IR emitter. You'll see a purple glow in the center of the IR LED.)

Working principle of L293D motor driver IC

L293D is a motor driver IC. It is used to drive the motors (hence the wheels of the robot). As shown in the pinout of the L293D IC, it can control two motors. It can change the speed of the motor based on the current supplied to it; it can control the direction of the motor based on the input; it can also start or stop the motor.

Circuit diagram for building a line following robot without a microcontroller

A complete schematic of the Line Follower robot using the L293D and IR sensor is given below:

As you can see, we have divided the black wire follower robot circuit into three parts, two of which are used to build the IR sensor and the other part is used to build the controller circuit using the L293D motor driver IC.

Building an Infrared Sensor Using the LM358

The circuit connection between the pins of LM358 and the IR sensor is shown in the figure below. We use a single LM358 IC to control two IR sensors. The LM358 is powered using VCC and GND pins 8 and 4 respectively. The LM358 is an op amp comparator IC that provides a high output (VCC, 9V in our case). The photodiode is reverse biased and a 100k resistor is used to create a voltage divider and fed as input to the inverting terminal. Another voltage divider is created using the 10k preset and provided as an input to the non-inverting pin 3 of the comparator. The IR LED is powered up by forward biasing using VCC and GND. Pin 1 is the output, so we connect the LED with a current limiting resistor and use the sensor's output from here as the input to the motor driver.

To summarize, we know that the voltage and resistance of a photodiode varies depending on whether a black or white surface is present. This voltage is used to compare with a reference voltage obtained by preset to give a high voltage or a low voltage. Use LEDs to indicate outputs.

L293D Motor Controller Circuit

Pins 4, 5, 13 and 12 are shorted to ground. Pin 16 is the VCC pin. These two pins supply power to the IC. Pin 8 is VCC, the voltage at which the motor runs and should be given here. Since we are using a 9V battery, we will short the two VCC pins (pin 8 and pin 16) and supply it directly to 9V. Pins 1 and 9 are the enable pins for their respective motors; for our connection, we need the motors to run as soon as they get input from the IR sensor, so we connect the enable pins high (shorted with VCC it). Pins 3 and 6 should be connected to one motor and pins 14 and 11 should be connected to the other motor. Now, we have two pins for sensor output. This is used to run the motor in forward or reverse. Since our robot will only move forward, we can connect pins 7 and 10 to ground and connect the IR sensor output to pins 2 and 4.

To summarize these connections, when there is a high input from the IR sensor, the robot moves forward. When there is a white surface under the robot, the infrared sensor provides high output, so the motor turns forward. If both IR sensors hit the black surface, it will provide low output, so the motor won't run. At this point, the robot stops moving. However, if there is only one IR sensor going through the black surface, that sensor has a low output, and the other IR sensor on the white surface will provide a high output, so the side motors will still turn, so the robot turns.

The assembly line follows the robot

Once we understand how all the components are connected, we can start assembling our line follower robot. To make this robot, first, we need a robot chassis. Here, we used a simple off-the-shelf robot chassis. We then placed the BO motor with the IR circuit and controller circuit onto the chassis with the help of some hot glue as shown in the picture below.

To power the robot, it is best to use a Li-Ion battery (like 18650) and a boost converter (convert 3.7V to 5V), as a simple 9V battery won't run the robot. But with the 18650, the charging circuit should also be included, which makes the circuit a bit complicated. So here we used two 9V batteries combined in parallel. A single 9V battery cannot output enough power to drive the motor and IR circuit; therefore a parallel combination must be used. Both the L293D and the IC 358 can accept input voltages up to 9V, so use that here. If using a voltage higher than 9V to power the circuit, check the input voltage in the datasheet for the L293D and IC 358 (as higher voltages may damage the IC).

Test and Calibration

We've assembled the robot, and since it doesn't require any code, it's time to see it in action. To do this, all we need to do is place the robot above the black line and see it in action.

Advantages of designing a line-following robot without a microcontroller

We learn to design basic logic circuits, which give us an understanding of how microcontroller logic works.

We built an infrared sensor and understood how it works.

Without the microcontroller, the cost of the entire project is reduced.

Since there is no microcontroller, no programming is required.

The circuit is simple and helps reinforce basic electronics concepts.

Limitations of designing a line-following robot without a microcontroller

The robot cannot make a 90 degree turn.

The robot runs in a jumping motion instead of a smooth motion (this can be fixed using a PID controller and microcontroller).

When both sensors detect the black line, the robot stops moving.

Leave a Reply

Your email address will not be published.