Very Simple Line Follower for Beginners
by Nikus in Circuits > Arduino
15923 Views, 32 Favorites, 0 Comments
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:
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
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
Downloads
Connection
Downloads
Battery
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
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
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!
Facebook: https://goo.gl/ZAQJXJ
YouTube: https://goo.gl/x6Y32E
Instagram: https://goo.gl/JLFLtf
Twitter: https://goo.gl/JLFLtf