Line Follower Arduino

              Line Follower is a very simple robot ideal for beginner electronics. The robot travels along the line using the iR sensor. The sensor has two diodes, one diode sends infrared light, the other diode receives the reflected light from the surface. When the infrared rays fall on the white surface, they are reflected back. When infrared light fall a black surface, the light is absorbed by the black surface and no rays are reflected back, so the photodiode does not receive any light. The sensor measures the amount of reflected light and sends the value to the arduino. There is a potentiometer on the sensor, with which we can adjust the sensitivity of the sensor.

Arduino now has to make decisions based on the data received from the sensor, until the sensor detects no black line it will go forward. If the left sensor detects a black line, the robot turns right, and if the right sensor detects a black line, it turns left. The robot will stop when both sensors detect a black line at the same time.

Version with L298N Shield:

To assemble your robot you need:


Now before turning on the power, check that you have connected everything correctly. Copy the program code and upload it to your arduino, then turn on the serial monitor (in Arduino IDE -> Tools -> Serial Monitor). Place your robot on the black line and set the potentiometer so that the sensor value shows ≈ 1023, and on the white surface ≈ 33.

Copy the code below and upload it to arduino. Have fun 🙂

Version with L293D Shield:

Download the latest version of the library for L293D Shield from

To add a library Go to Tools -> Inclde Library -> Add .ZIP Library. And select

Leave a Reply