" alt="Cancel" title="Close" />

I can sense that you are preparing for Avishkaar League IRC Qualifier, aren’t you? Because only a true innovator would look out for tips & tricks to program a line follower robot efficiently. And with that thought, let’s begin!

First things first, We know you are aware but if you are new to robotics, you are probably wondering – “What is a Line Follower Robot?”

Well, to give you a gist of it – A line follower robot is a smart machine, designed to follows a track printed on a surface. The robot will perform various actions while following this track.

Before we begin with the programming part, let’s talk about the construction a bit or “How to Make a line follower Robot?”

We are using an Avishkaar ABot Advanced Kit for building this bot.

Construction of the Bot

  • Let’s start with creating a three wheel robot.
  • Start by attaching the motor & the wheels in the center of the robot. Motor position is an important part of Robot design, this will help in accurate motion of our line follower Robot.
  • Next we need 2 sensors to detect the line, You can use IR sensor or Color Sensors based on the line track, If it is a black line track, you can use IR sensors, while for any other color you need to use the color sensors.

How to Program a Line Follower robot?

To program the line follower robot, we need to first understand, the values we are getting from our sensors.

  • IR sensor return a value of 1023 on White & 0 on black.
  • While Color sensors returns a character “W” on white & “X” on black.
  • We can check this by printing the sensors values on the screen using this piece of code.

A bit of advice, Printing sensor values is very crucial for your robot, because it will help you debug your robot in case of a deviation.
Always try to have a flexible joint for your sensors, this will help you adjust them for different light conditions. 

Now, when are sensors are working fine, we will now proceed with the different if-else conditions

There are Four Simple Conditions of the robot- 

  • Both Sensors on White Color – In this condition, the robot is facing straight & both the sensors are on White. So both the sensors will return 1023, which is not equal to zero to the controller. When the robot is in this condition we will program the robot to move in forward direction.
  • Left Sensor on Black & Right Sensor on White Color – In this condition, the robot is tilted to the right side. The LEFT sensor is on Black & RIGHT sensor is on White. Hence The LEFT sensor will return a 0 & RIGHT sensor will return 1023. The robot will be programmed to turn left in this case until the condition is changed.
  • Left Sensor on White & Right Sensor on Black Color – This condition is similar to the last condition but just opposite to it. The RIGHT sensor is on Black & LEFT sensor is on White. Hence The LEFT sensor will return a 1023 & RIGHT sensor will return a 0. The robot will be programmed to turn right in this case until the condition is changed.
  • Both Sensors on Black – The robot is now facing straight & both the sensors are on Black color Intersection.

This is the most important condition of a line follower robot & in most cases the robot deviates after reaching this condition only. Let’s understand this in detail. In any line follower arena, there are several intersections & on each intersections, the Robot is required to perform various actions.

Let’s start by counting the intersections on our arena – Download Arena File

We have Total 6 intersections & the robot will perform these tasks on each intersection:

  • Intersection 1 – Rotate 90 degree Right
  • Intersection 2 – Rotate 180 degree Right
  • Intersection 3 – Rotate 90 degree Right
  • Intersection 4 – Rotate 180 degree Right
  • Intersection 5 – Stop for 1 second & move forward
  • Intersection 6 – Stop completely

Now, let’s program our robot to detect these intersections and count them. 

For this We’ll use a variable named ‘Count’, initially set to 0. We’ll increment this count by 1 each time both sensors detect black. Next, For different tasks, we’ll add conditions based on the value of ‘Count’.

  • If Count = 1, In this condition, The robot needs to rotate 90 degrees in right direction. Here we will not be using a delay to rotate the robot, as timing based turns often leads to deviation.

Instead, we’ll use sensor-based logic for the turn. The Logic is simple, Turn the robot until the right sensor detects white. We can use a Repeat While loop for this. We also need to redefine the variables to read the sensor values. Now, This loop should turn the robot while the right sensor is on black. As soon as the sensor reaches white color, the turning will stop.

Let’s test this code.  It didn’t work right, and that’s because how we are turning the robot.

There are two types of turning.

  • Full Turn – In this type both the wheels rotate in opposite directions, making the robot turn from its center. Hence the robot’s turning radius will be less.
  • Curve Turn – In this method we stop one wheel & rotating other, allowing the robot a bigger turning radius because the pivot point or the axis of rotation will get change from center to side. 

So we will use the curve turn method, & you can see the robot is now taking perfect 90 degree turn.

  • If Count = 2, In this condition, robot needs to rotate 180 degrees. We will use two loops for this:

1: Repeat While the right sensor = 0, Here we do not want a bigger turning radius, so we will use Full Turn logic. This loop will turn the robot halfway. 
2: Repeat While the right sensor is not equal to 0, This loop will now rotate the robot further in right direction until the right sensor falls on black color.
And with this simple logic, our 180 degree turn is completed, without using any time block.

The next intersection is similar to the first intersection, so we will modify our condition, Now on intersection 1 & 3, the robot will take a 90 degree turn.
Similarly on 2 & 4, robot will rotate 180 degrees.

The next intersection requires a time based action, so here we can use a time delay to stop the robot. Along with a loop to move forward until the sensors detect white. Lastly we can finally stop our robot to complete the arena run.

Now go ahead and try it out for yourself! Good luck for your competition.

Hope we made it easy to follow. In case you don’t have the Avishkaar ABot Advanced Robotics Kit – you can go ahead and check it out.

This image has an empty alt attribute; its file name is how-to-make-a-line-follower-slide-1-1024x570.jpg

This is a beginner’s robotics kit which comes with a bunch of metal parts, motors, sensors, nuts & bolts and a programmable brain and can be used to make up to 10 programmable robots. There is a detailed manual inside as well which will help you understand how to build and code different robots.

The interesting thing about this kit is that it is part of a much larger modular robotics design system by Avishkaar which means even though you can only build 10 robots using the kit, you can easily upgrade to some of the more advanced robotics kits by Avishkaar using our bridge kits.

The parts in this kit will still be compatible with the advanced kits and you’ll be able to build hundreds of many more advanced robots.

There is a detailed manual inside which will help you understand how to build and control it. Watch this video below for a detailed tutorial.

Embark on your robotics journey today with Avishkaar’s beginner-friendly projects and unlock the endless possibilities of the robotics world!

Join our fabulous community of young, innovative Avishkaaris on WhatsApp here – Let’s Avishkaar Express
Discover all Avishkaar kits here.

Thank you for taking the time to read this blog post! We hope you found it informative and enjoyable. If you’d like to stay updated on future articles, exclusive content, and exciting announcements, we invite you to subscribe to our newsletter.

By subscribing, you’ll be the first to receive our latest posts right in your inbox. You’ll also gain access to special offers and opportunities that we only share with our subscribers.

To subscribe, simply enter your email address in the form provided below.

Recommended Articles

Leave a Reply

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