Hit enter after type your search item
Home / Arduino / LDR based line following robot using Arduino and Ardumoto

LDR based line following robot using Arduino and Ardumoto


Let’s start with the list of components required for making an LDR based line following robot.

1 . Arduino- obviously !

2. Ardumoto – You can buy one from buildcircuit.com.au

try this also
3. A robot chassis- you can buy one from sparkfun.com or from this link: 70108 Tracked Vehicle Chassis

4. 4x Current limiting resistors: 220Ohm.

5. 3×1 k Ohm resistors.

6. 4 x White LEDs- Should be bright.

7. 3x Light dependent resistorsBUY NOW

8. 2 x DC motors- If you get a robotic chassis from BuildCircuit , you get 2 DC motors along with the robot chassis. CHECK OUT THE CHASSIS

9. Battery pack- 6V

10. Wires/connectors.

What is the logic behind a line following robot?

There are basically two ways of building a line following robot. First, using a light dependent resistor(LDR) and second, using Infrared(IR) LEDs.  A dark object reflects less light than a bright object ( a dark object absorbs more light than a bright object) this is the only fundamental logic behind a line sensing robot. So, basically a line following robot distinguishes a black line from a white surface.

The circuit for making LDR based line sensing robot:

Download in pdf format


If you have never worked with Ardumoto or LDR, follow these links:

a. LDR Projects.

b. Ardumoto

Test your sensor:
Before you start assembling the sensor onto your robot chassis, check your if sensor is detecting the black and white surfaces properly. I have written a post about testing the sensor, FOLLOW THIS LINK.

How to assemble?

The most difficult part of this project is to make a combination of LDRs and LEDs. Even a small mistake can take your robot out of black line. There follow the instructions carefully.

– Solder the LEDs as shown in the picture.


You can see that the LEDs are connected at a difference of exactly 4 solder holes. Now, solder LDRs by the side of each LED, except the one close to my thumb.

You should have this arrangement: LED1(close to my thumb)2 holesLDR1-LED22 holes LDR2LED3 2holesLDR3 LED4

Second important thing you should remember is that the LDRs should be slightly above the LEDs, so that they get the reflected lights properly.

This is the correct arrangement.

Now, connecting the sensor circuit to Aduino pins:

Just follow the picture shown below:


Your sensor should be around 5-7mm above the black line.

The turns should be made smooth, not sharp because the LDRs won’t sense quick transition. I have made a circular path. And I made the black line using a black board marker, you can try with electric tape also.



try this also

  • Facebook
  • Twitter
  • Linkedin
  • Pinterest


  1. hi good day. i was making my line follower robot with arduino uno combine with arduino motor shield, with LDR base sensor. my problem is when i test it the dc motor will not get turn on. i supply 6v. can anybody help me please????

  2. hey,
    i was wanted to know the code for arduino in this project.This is because without the arduino code,the robot will not move.
    Please reply fast!!!

  3. Good job man

    i have a question. if you changed the surrounding light environment. the readings on from the LDRs will defiantly change ,right ?

    • it does change but its barely noticable and if one reading on a ldr changes it changes equaly on the other two. Its beacuse they are so close to the ground and the leds are all they percieve. In my code i added a serial comunication to see this.

  4. Great Algorithm and Logic of code.. Just one query.. What is the purpose of “offset”, you used in the code ? And I’m having an issue with my bot… That at same PWM, motors turn with different speed which causes the bot to rotate instead of going straight… Any help will be highly appreciated, Thanks…!

Leave a Comment

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

fifty one − = forty four

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This div height required for enabling the sticky sidebar
Ad Clicks : Ad Views : Ad Clicks : Ad Views : Ad Clicks : Ad Views : Ad Clicks : Ad Views : Ad Clicks : Ad Views : Ad Clicks : Ad Views : Ad Clicks : Ad Views : Ad Clicks : Ad Views : Ad Clicks : Ad Views :

Please Subscribe

Thank you!