HomeArduino ProjectsLine Follower Robot Car with Arduino UNO, L298N Driver, IR Sensor

Line Follower Robot Car with Arduino UNO, L298N Driver, IR Sensor



Make Arduino Line Follower Robot Car with Arduino UNO, L298N Motor Driver, IR Sensor

In this short descriptive article, I will show you how to make a Line Follower Robot Car using Arduino UNO and 2 IR Sensor Modules. The name Line follower name suggests a Fully Automated Car. That follows a visual line (Most likely white or Black) that is embedded on any floor or any surface.

This project is based upon a microcontroller more specifically Arduino. But it is also possible to develop a line follower robot without a microcontroller. But there will be limited functionality and the stopped will be lower than any microcontroller-based vehicles.

Because the data processing power of the Microcontrollers is greater than simple Op-Amp ICs. This will be a basic line follower robot project report ppt.

Watch YouTube Video:

Here is the video from Make DIY YouTube Channel. Watch the full video and it will be easier for you for replicating the project.

Arduino Line Follower Robot with IR Sensor, Arduino Uno and L298N Motor Driver

How does the Line Follower Robot Car work?

This is a simple Microcontroller-based car. Let me tell you in detail how the thing works. The car consists of 2 IR sensors.

This sensor senses the line color is reflective or not. Here reflection means the surface sends back the light. In this case, the reflective surface is the White surface. (The non-reflective surface is the black lines only.) It means that that black tracks don’t reflect any light back.

The working of the sensor is that it senses is there any reflective light coming back or not. then only the sensor will give the output(Output two types. I will discuss that later). And if there is no reflection then the IR sensor will not give any output or in other words, the output will be low.

Based on this High and Low Output results the microcontroller can control the car.

The microcontroller gives the direction to the car where to go and then when to take turns (Left or Right) and where to stop (I created the code in such a way if the 2 sensors get Black Surface then it will tell the microcontroller to stop the car.).

Things Needed for Arduino Line Follower Robot Car

Amazon.com Links

Amazon.in Links

Popular Categories:

  1. Circuits
  2. Arduino Projects
  3. DIY Projects

Schematics for Arduino Line Follower Robot Car:

Arduino Line Follower Robot with IR Sensor, Arduino Uno and L298N Motor Driver
Arduino Line Follower Robot with IR Sensor, Arduino Uno and L298N Motor Driver

Steps for making the Car:

Step 1:

First, we will need a wood piece as the car chassis. Here I am using 13CM x 10CM Plywood as the car chassis. These dimensions are ideal for making a TT Motor Car. You can also use an Acrylic sheet or Premade chassis also.

Step 2:

Now attach the motors on the 4 corners of the Plywood with a Glue gun or any other glue. Make sure when you are attaching the motors then the motor alignment should be correct. Otherwise, the car will not go straight.

Step 3:

Now connect the TT Gear Motors as shown below. We will connect the motors in criss cross pattern. This is because we have to make the car in such a way that two side motor rotates in same direction in order to go Forward Backward and other known directions.

Step 4:

After Connecting motors, the connection should look like this. Here I provided both side pictures for you to understand clearly what is going on.

Step 5:

Here we are using L298N Motor Driver. I used double-sided tape for connecting the L298N Motor driver on the Plywood. You can also use Nut and bolts for this.

Step 6:

Now connect the motor wires with the L298N Motor Driver. And then Tighten the motor driver wires. and avoid any type of loose connection.

After connections all wires will look like this.

Note: After uploading the code if the car is not going in the right direction or if it is rotating in the wrong direction then just change the motor wires. And it will just work just fine.

Step 7:

For the Battery, I am using 2, 18650 batteries. This is great for making this type of car. For connecting the batteries I am using a 2s 18650 Battery holder. I also added a switch for turning on/ off the car.

The battery wires will be connected with the motor driver input wires. You can also clearly see where to connect the battery wires.

Step 8:

In this project, I am using Arduino Uno as a Microcontroller. You can also use any other microcontroller as your wish. But in that case, the wiring schematics will be different.

Next, you have to remove the Jumper shorted connectors from the motor driver for the next step of connection.

Step 9:

In the picture I have mentioned the necessary connections for the motor driver.

Arduino UnoL298N Motor Driver
Pin 10ENA
Pin 9IN1
Pin 8IN2
Pin 7IN3
Pin 6IN4
Pin 5ENB

Step 10:

Connect the IR Sensors as I showed in the photo. Then connect the necessary wires with the Arduino UNO. Just Follow the Wiring Diagram in the schematics.

Now Upload the code to Arduino. Now we have to do the calibration for running the car.

Step 11:

Connect the batteries to the car and turn on the switch.

Step 12: (Sensor Calibration) *** IMPORTANT***

Before calibrating you must connect the wheels to the car. You don’t need to open the serial monitor for calibration. It is just manual calibration. Here I used the digitalRead function to differentiate between Light and Dark. So, the IR Sensor will just give High/ Low as the Output.

Place the car on some High surface. Here I used a Top cover of Spray Paint to place the car on it for calibration. Here I am using the White surface couple with a T-shaped line for calibration. (Those who are thinking about what I used for the T Shape. Here is the answer, This is simple Black Electrical tape )

Place the car As I Showed in the picture. Now You are ready to calibrate. First Rotate the 2 Potentiometers (Left & Right side sensors both) full Counter-clockwise.

  • Now Rotate the Potentiometers one by one slowly clockwise till the LED of the IR Sensor Turns on.
  • Next, slowly move the car to the Left and Right in such a way that the car Left and the Right sensor will be on the black line. and then the car wheels rotate in a different direction.
  • More specifically, If you put the Left Sensor on the black line the car will try to move in the right direction. Similarly, If the right sensor is in dark then The car moves in the Left direction.
  • This is because to place the car all-time on the Blackline. One main corn of this configuration is that you can’t go too fast in this configuration. As a beginner project, this is great.

So, the calibration process is bit easier in this case. Now you can turn on the car and place on the where you want to follow and the car will follow the line.

Arduino Line Follower Car Code:

Simple troubleshoot if the car is not going in the right direction:

If this happens and your car is not going in the right direction then you don’t have to modify any code. You have to just change the motor driver wires.  Now your car will go in the right direction. 

Line follower Car Demo

Simplified PCB:

I have also created a simplified PCB for the Line follower Robot car that you can order from PCB manufacturing company PCBWay. It will provide a more professional look to the car.

I have designed the Schematics in EasyEDA.

All necessary connections are provided to the car like Power In, L298N Motor Driver Pinout, Left IR sensor, and Right IR sensor pinout.

PCB Layout

Here I used Atmega328P Microcontroller. This IC is also used in Arduino Uno R3. So, we will just program the Arduino UNO R3 and remove the chip from UNO Board and place it on the PCB. This will give the minimal look to the Car.

PCB 3D View

How to order PCB?

Go to PCBWAY.com and then click on Instant Quote. Now here are the basic settings for publishing a post.

  1. First, Give the PCB Dimensions. PCBway has great deals on 100mm x 100mm PCBs.
  2. Select the Number of PCBs you want to order.
  3. For prototype PCBs, you can order 5 Samples and upwards.
  4. Choose 2 Layer PCB.
  5. General PCB thickness is 1.6mm which is ok for hobby projects.
  6. Click on the Quote Now.

Submitting PCB Design to PCBWAY

Here is the typical PCB Submitting Page. You will find all types of PCB customizations here. Like Board Type, Size, Layer, Thickness, and much more.

  1. PCBWAY supports multilayer PCBs such as 14 Layers PCBs also. Now you just need to upload the PCB. PCBWAY will take care of all the certain parameters of the PCB.
  2. After that, it comes to the payment part. In this case, you can use any credit card, Debit Card, or PAYPAL.
  3. They have 128 bit SSL encryption on their server. Within a week you will receive your PCB and use it for the Arduino Line follower car.

PCB Gerber Link: Download


All in all this is a great car for hobbyists. Make sure you do all the steps I have shown in the video. The speed of the car is low for following the line efficiently. If you want to speed up the car then you can use IR Array. But it is a topic for another video. Hope you guys enjoyed by making this car.

I have also provided How to speed up the car while going to straight lines and angular rotation in the code. Just change the speed parameter according to your car. Don’t make the speed parameter too much otherwise, the car will not able to make any quick rotation.

This is the only corn of the car. It is a great project for hobbyists. You can make this for fun projects as well as science projects.

You can also read another article about Arduino projects.



  1. Hello!
    Thanks for the nice description and video about the line follower robot.
    Unfortunatley it doesn’t work for me. I made everything as I saw but when I connect the battery I only hear ticking noise and nothing happens. With this ticking noise the L led on my Uno also flashes.
    Could you help me please, what can be the problem?
    Thank you in advance!

Comments are closed.

- Advertisment -