Kshitij Tiwari Ph.D.

Start your robotics journey with a line follower robot

7 min read

If you have never built a mobile robot in your life and want to take on a fun robotics project, a line follower robot would be a good place to start. Line follower robots are able to move along a line and make simple decisions to ensure they follow the line as closely as possible.

 

Let us look into what goes behind the scenes in making a line following robot- both the hardware and software needs and what all you can learn in the process.

 

Where are line following robots used?

Line follower robots may sound naïve, but are often used in robotic competitions, to get a robot to navigate through a predefined path.  Line follower robots can also be used in certain industrial applications, like automated warehouses and manufacturing floor logistics.

What are the components of a line follower robot?

Building a line follower robot requires a few basic supplies. These include a small microcontroller, such as the Arduino, wires, motors and sensors. Additionally, you will need a set of batteries and wheels to power up the robot and move it around.

As for the chassis, it can be a very simple build such as a segway robot built using the LEGO Mindstorm NXT 2.0 kit, an arduino based DIY robot car, or, any other design you can imagine.

Sensors used for the line follower robot

The most important component of the line follower robot is the sensor that it uses to detect the line and make sure it follows it. Typically, the most common type of sensors used for line following robots are infrared (IR) sensors. These sensors can detect the difference between the bright line, and the dark background.

How many sensors does a line follower robot need?

Ideally a line follower robot would comprise of 2-3 IR sensors to detect if it is undershooting or overshooting the line to the right/left.

In case of 2 IR sensors, you would want to place one IR sensor along each interior and exterior border of the track such that when both sensors detect the track, the robot is following the line. In case only one of them detect the track, the robot is off the track and needs to correct its course.

In case of 3 IR sensors, the one in the middle is ideally place on top of the line/track. The other two are ideally placed are over the surface just outside the outer boundary of the tracks.

One could also argue, that building a line follower robot with a single IR sensor is also possible. Rightly so, it is very possible though the control logic can become slightly tricky with a single IR sensor only offering limited information.



Steering the line follower robot

Steering is a crucial aspect of controlling a line follower robot, which is designed to follow a specific path or track a line marked on the ground. The steering mechanism determines how the robot maintains its position relative to the line and makes the necessary adjustments to stay on course.

Line follower robots often employ differential drive as their steering mechanism. This mechanism utilizes two independently powered wheels, with each wheel driven by a separate motor. By varying the speed and direction of each wheel, the robot can turn, follow curves, and adjust its position along the line.

Assembling the components for line follower robot

Once you have the supplies, it’s time to start putting the robot together. First, connect the microcontroller to the motor and sensor. Then, attach the navigation wheel to the motor, allowing it to freely rotate. Next, wire the motor and motor control circuits and connect the motor to the microcontroller. Finally, add the batteries and you’re ready to start programming!

 

How does a line following robot work?

Now that the robot is all assembled, it is time to build some decision making abilities for the robot to be able to follow a line. The rationale behind the line follower is quite simple:

Step-1: Draw a line/track to follow

The first step is to draw a track or a line for the robot to follow. This will typically be a black line on a white background, which will be detected by the robot’s sensors.

Step-2: Detect if the robot is off the line

Once the robot is set up and ready to go, the robot’s sensors will detect the black line in a given environment. If the robot detects that it is on the line, it will follow it. If the robot detects that it is off the line, it will take corrective action and adjust its position so that it can get back onto the line.

Step-3: Taking corrective actions to follow the line

To turn the robot in the correct direction, the microcontroller will compare the readings from the sensors and determine the direction in which the robot should turn: left or right, in order to stay on the line. The microcontroller will then send commands to the motors to execute the desired movement.

If you simply try to turn the right/left motors on/off, you will end up with a zig-zag behavior. To obtain a smoother correction, you would need to proportionately control the left and right motors simultaneously to maintain the course.

For proportionate control of the motors, one could employ the PID (Proportional-Integral-Derivative) controller.

 

What next after building a line follower robot?

Think of a line follower robot as a minimalistic robot with a pea sized brain (it’s microcontroller). There is a very simple autonomy on-board by virtue of the PID controller but it isn’t a very fancy robot per say.

The next step could be to think about a robot that has more flexibility to roam freely in its environment instead of being tied down to a line. Think about adding localization and mapping abilities for your robot and drop it in an arena similar to the Robocup- a league for robot soccer.

Key takeaways

Building a line follower robot is a fun and rewarding experience. With some patience and practice, you can get it up and running and see it in action! Through the assembly and programming, you will learn a lot of valuable skills and gain knowledge on robotics that you can apply to other projects in the future.

The basic principles of line following robots can also be applied to more complex robots, such as those for navigation and mapping. So, if you are interested in robotics and want to take on a challenging project, consider building your first line follower robot!