Very Simple Line Follower for Beginners
by Nikus in Circuits > Arduino
15692 Views, 32 Favorites, 0 Comments
Very Simple Line Follower for Beginners
![mini.jpg](/proxy/?url=https://content.instructables.com/F3B/K8EZ/JA8J9OVF/F3BK8EZJA8J9OVF.jpg&filename=mini.jpg)
![Very Simple Line Follower for Beginners with Arduino](/proxy/?url=https://content.instructables.com/FXY/KODQ/JA8JBT8L/FXYKODQJA8JBT8L.jpg&filename=Very Simple Line Follower for Beginners with Arduino)
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:
Facebook: https://goo.gl/ZAQJXJ
YouTube: https://goo.gl/x6Y32E
Instagram: https://goo.gl/JLFLtf
Twitter: https://goo.gl/JLFLtf
Ready to build your first line follower? That’s great! :)
Let’s start!
Parts
![simple_line_follower.Film.Movie_Migawka.jpg](/proxy/?url=https://content.instructables.com/FPU/6YKT/JA7I1WPB/FPU6YKTJA7I1WPB.jpg&filename=simple_line_follower.Film.Movie_Migawka.jpg)
![simple_line_follower.Film (2).Movie_Migawka.jpg](/proxy/?url=https://content.instructables.com/F7W/ECBS/JA7I1WNF/F7WECBSJA7I1WNF.jpg&filename=simple_line_follower.Film (2).Movie_Migawka.jpg)
![simple_line_follower.Film (3).Movie_Migawka.jpg](/proxy/?url=https://content.instructables.com/F3N/16S6/JA7I1WMC/F3N16S6JA7I1WMC.jpg&filename=simple_line_follower.Film (3).Movie_Migawka.jpg)
![simple_line_follower.Film (4).Movie_Migawka.jpg](/proxy/?url=https://content.instructables.com/FJR/KD7J/JA7I1WJD/FJRKD7JJA7I1WJD.jpg&filename=simple_line_follower.Film (4).Movie_Migawka.jpg)
![simple_line_follower.Film (5).Movie_Migawka.jpg](/proxy/?url=https://content.instructables.com/FOT/P09Z/JA7I1WJ8/FOTP09ZJA7I1WJ8.jpg&filename=simple_line_follower.Film (5).Movie_Migawka.jpg)
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 a link to the 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.
Assembling the Chassis
![simple_line_follower.Film (6).Movie_Migawka.jpg](/proxy/?url=https://content.instructables.com/FRI/M30R/JA7I1WFO/FRIM30RJA7I1WFO.jpg&filename=simple_line_follower.Film (6).Movie_Migawka.jpg)
![simple_line_follower.Film (7).Movie_Migawka.jpg](/proxy/?url=https://content.instructables.com/FHO/MSGG/JA7I1W9U/FHOMSGGJA7I1W9U.jpg&filename=simple_line_follower.Film (7).Movie_Migawka.jpg)
![simple_line_follower.Film (8).Movie_Migawka.jpg](/proxy/?url=https://content.instructables.com/F1I/GFE5/JA7I1VSG/F1IGFE5JA7I1VSG.jpg&filename=simple_line_follower.Film (8).Movie_Migawka.jpg)
![simple_line_follower.Film (9).Movie_Migawka.jpg](/proxy/?url=https://content.instructables.com/FZG/R4DQ/JA7I1URU/FZGR4DQJA7I1URU.jpg&filename=simple_line_follower.Film (9).Movie_Migawka.jpg)
Downloads
Connection
![schematic.png](/proxy/?url=https://content.instructables.com/F0W/JJZT/JA7I1ZD0/F0WJJZTJA7I1ZD0.png&filename=schematic.png)
![simple_line_follower.Film (10).Movie_Migawka.jpg](/proxy/?url=https://content.instructables.com/F9D/JWQF/JA7I1UG1/F9DJWQFJA7I1UG1.jpg&filename=simple_line_follower.Film (10).Movie_Migawka.jpg)
![simple_line_follower.Film (11).Movie_Migawka.jpg](/proxy/?url=https://content.instructables.com/FW5/R98C/JA7I1U7L/FW5R98CJA7I1U7L.jpg&filename=simple_line_follower.Film (11).Movie_Migawka.jpg)
Downloads
Battery
![simple_line_follower.Film (24).Movie_Migawka.jpg](/proxy/?url=https://content.instructables.com/FXC/BGU6/JA7I24DA/FXCBGU6JA7I24DA.jpg&filename=simple_line_follower.Film (24).Movie_Migawka.jpg)
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.
Upload a Program
![simple_line_follower.Film (12).Movie_Migawka.jpg](/proxy/?url=https://content.instructables.com/F2W/SK2K/JA7I1U4O/F2WSK2KJA7I1U4O.jpg&filename=simple_line_follower.Film (12).Movie_Migawka.jpg)
![simple_line_follower.Film (13).Movie_Migawka.jpg](/proxy/?url=https://content.instructables.com/FS1/TH7C/JA7I1TQ2/FS1TH7CJA7I1TQ2.jpg&filename=simple_line_follower.Film (13).Movie_Migawka.jpg)
![simple_line_follower.Film (14).Movie_Migawka.jpg](/proxy/?url=https://content.instructables.com/FKS/BPU5/JA7I1T2K/FKSBPU5JA7I1T2K.jpg&filename=simple_line_follower.Film (14).Movie_Migawka.jpg)
![simple_line_follower.Film (15).Movie_Migawka.jpg](/proxy/?url=https://content.instructables.com/FPV/UXAD/JA7I1SST/FPVUXADJA7I1SST.jpg&filename=simple_line_follower.Film (15).Movie_Migawka.jpg)
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); }
Downloads
Make a Line
![simple_line_follower.Film (16).Movie_Migawka.jpg](/proxy/?url=https://content.instructables.com/F73/IEEN/JA7I1SMR/F73IEENJA7I1SMR.jpg&filename=simple_line_follower.Film (16).Movie_Migawka.jpg)
Have Fun!
![simple_line_follower.Film (23).Movie_Migawka.jpg](/proxy/?url=https://content.instructables.com/F9Q/KFLV/JA7I1S9J/F9QKFLVJA7I1S9J.jpg&filename=simple_line_follower.Film (23).Movie_Migawka.jpg)
![simple_line_follower.Film (17).Movie_Migawka.jpg](/proxy/?url=https://content.instructables.com/F14/GXRU/JA7I1SMQ/F14GXRUJA7I1SMQ.jpg&filename=simple_line_follower.Film (17).Movie_Migawka.jpg)
![simple_line_follower.Film (18).Movie_Migawka.jpg](/proxy/?url=https://content.instructables.com/FMR/B9BC/JA7I1SGQ/FMRB9BCJA7I1SGQ.jpg&filename=simple_line_follower.Film (18).Movie_Migawka.jpg)
![simple_line_follower.Film (19).Movie_Migawka.jpg](/proxy/?url=https://content.instructables.com/F39/ITPD/JA7I1SER/F39ITPDJA7I1SER.jpg&filename=simple_line_follower.Film (19).Movie_Migawka.jpg)
![simple_line_follower.Film (20).Movie_Migawka.jpg](/proxy/?url=https://content.instructables.com/FDG/WBW2/JA7I1SCR/FDGWBW2JA7I1SCR.jpg&filename=simple_line_follower.Film (20).Movie_Migawka.jpg)
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!
Facebook: https://goo.gl/ZAQJXJ
YouTube: https://goo.gl/x6Y32E
Instagram: https://goo.gl/JLFLtf
Twitter: https://goo.gl/JLFLtf