Very Simple Line Follower for Beginners





Introduction: Very Simple Line Follower for Beginners

A lot of people want to start building robots but don’t know how to start and what to build first. Some time ago I have made a very simple robot for beginners that avoids obstacles, a lot of people like this project so much that I have decided to make a second version of this project. This time we will make a line follower robot, that’s very popular type of robot that is a little bit more sophisticated than object avoiding one. You can even see line followers on robotic competitions, check it out on YouTube, they are so fast! Our robot wouldn’t be so fast it will be like a introduction to robotics, just to let you make your first robot and get some knowledge to build better ones in the future. I promise to keep things as simple as possible to let everyone make it and understand it. Before we begin let’s answer one question, what is a line follower? That’s the robot that follows the line thanks to sensors on the bottom of it it recognize line that is black and decide whether it should turn right or left or maybe just go forward.
Before we begin follow me on my social media:

Follow me on social media:




Ready to build your first line follower? That’s great! :)
Let’s start!

Step 1: Parts

To start building our robot we have to buy some parts or just a kit that includes all of them. Chassis of the robot and parts may look a little bit different then the one that I have but that is not a problem. You can buy chassis with 2 wheels like I or with 4 wheels it will also works well.
Here is link to chassis:

Here are links to all of the parts separately:

You may also need one 3d printed part to mount line sensors on the bottom of chassis but you can try to do it without a 3d printer or maybe if your chassis will be designed to easily attach them you wouldn’t need this part.

Step 2: Assembling the Chassis

Before connecting all of the componnents to Arduino we have to mount motor driver, Arduino and line sensors on the chassis. Easiest way to do it is to use distances that you should find in any robot kit and M3 screws. Below you can find .stl of the line sensors holder just in case you will need it. Make sure that everything is fixed securely.

Step 3: Connection

I think that fritzing schematic shows whole connection perfectly and there are no more things to say, but if you have any questions feel free to ask them in the comments, I am here to help! :) just to make it clear I added a image of motors connection to the stepper driver. Also check out video if you have any problem, maybe you will find solution in it. Before connecting power to Arduino make sure that connection is 100% ok to avoid and shorts, because you can damage Arduino or other parts.

Step 4: Battery

Powering robots is often a huge problem for beginners so I decided to make a separate step about it. What is in my opinion the best battery that you can use for this project? It is a lipo 2S or 3S depends on the motors that you use, also good one that I use is rechargeable 3S lion battery pack. I advice against using AAA batteries for that because they are not powerful enough for robotics, they cost a lot and don’t last too long. It maybe also a good idea to use some 18650 batteries or just a gel accumulator. No matter which battery you choose make sure that it’s voltage is not bigger than 12V to not damage Arduino and also not bigger than max voltage of your motors.
Capacity of the battery is not so important right there because it will only let you drive longer on single charge. 1000mAh is enaugh for this project but you can use bigger and smaller battery however you want, just don’t use too big one.

Step 5: Upload a Program

To upload a program just plu your Arduino to computer open my code, choose proper port and click upload. After uploading program to it we are almost ready to test it!
Program explanation:
At the beginning we initialize all of the ports and values, in the main loop of the program we check which sensor detects the line. If there is line only on the middle sensor robot goes forward. If left sensor detects line robot turns left, if right sensor detects line robot turns right. That’s just a very simple program to make it easy to understand for beginners. If you want to learn some more advanced line follower programming check out some info about line followers and PID algorithms on the google and let me know in the comments, if there will be some people that are interested in this topic I will make a instructable about it.

int pwm_speedA = 150;
int pwm_speedB = 145;

void setup() { pinMode(11, OUTPUT); pinMode(10, OUTPUT); pinMode(9, OUTPUT); pinMode(6, OUTPUT); pinMode(5, OUTPUT); pinMode(3, OUTPUT);

pinMode(2, INPUT); pinMode(4, INPUT); pinMode(7, INPUT);


void loop() { if(digitalRead(2) == LOW && digitalRead(7) == LOW && digitalRead(4) == HIGH){ forward(); }else if(digitalRead(2) == HIGH && digitalRead(7) == LOW && digitalRead(4) == LOW){ right(); delay(100); }else if(digitalRead(2) == LOW && digitalRead(7) == HIGH && digitalRead(4) == LOW){ left(); delay(100); } }

void forward(){ digitalWrite(10, HIGH); digitalWrite(11, LOW); digitalWrite(9, HIGH); digitalWrite(6, LOW);

analogWrite(5, 80); analogWrite(3, 80); }

void backward(){ digitalWrite(10, LOW); digitalWrite(11, HIGH); digitalWrite(9, LOW); digitalWrite(6, HIGH);

analogWrite(5, 80); analogWrite(3, 80); }

void left(){ digitalWrite(11, LOW); digitalWrite(10, LOW); digitalWrite(9, HIGH); digitalWrite(6, LOW);

analogWrite(3, 0); analogWrite(5, 100); }

void right(){ digitalWrite(10, HIGH); digitalWrite(11, LOW); digitalWrite(9, LOW); digitalWrite(6, LOW);

analogWrite(3, 100); analogWrite(5, 0); }

void motors_stop(){ digitalWrite(11, LOW); digitalWrite(10, LOW); digitalWrite(9,LOW); digitalWrite(6, LOW);

analogWrite(5, 0); analogWrite(3, 0); }

Step 6: Make a Line

This step is pretty simple, just make a line on the floor. As you can see my floor is quite dark but my robot still works very well on it. The easiest way to do it is to use black tape it is perfect for that! I advice you to make a simple circle without any fancy shapes because this simple robot can’t work so well on sharp corners

Step 7: Have Fun!

Last thing that you have to do is test your robot and enjoy it! Hope you are happy with your very first, very own robot! Let me know in the comments if you like this instructables, what you want to see next or if you had any problems.
Happy making, have a nice day and don’t forget to follow me on social media!







    • Pocket-Sized Contest

      Pocket-Sized Contest
    • Trash to Treasure

      Trash to Treasure
    • Paper Contest 2018

      Paper Contest 2018

    We have a be nice policy.
    Please be positive and constructive.



    i have two sensor ,can you tell what to now ? can i make with two sensor