# Education is not limited to just classrooms. It can be gained anytime, anywhere... - Ravi Ranjan (M.Tech-NIT)

## Line Follower Robot

What is line follower:

Line follower robot is an autonomous machine that can follow a path. The path can be seen like a white line on a black surface (or vice-versa) or it can be invisible as magnetic field.

Requirement of line follower robot:

Sensing a line and maneuvering the robot to stay on path, while constantly correcting wrong moves by using feedback mechanism forms a simple and effective closed loop system. As a programmer we get an opportunity to ?teach? the robot how to follow the line therefore it gives robot human like property of responding to stimuli.

Consider the practical application of line follower robot is:

• Guidance system for industrial robots moving on shop floor
• Automated cars running on road with embedded magnet.

Hardware Required:

• 12V, 1A DC Adapter-1 piece
• Analog IR Sensor-3 piece
• AVR Microcontroller Board-1 piece
• DC Motor Driver-1 piece
• AVR USB Programmer-1 piece
• 1 to 1 Connector-15 piece
• 10 to 10 FRC Female Connector-2 piece
• Robot-1 piece

Software Required:

• BASCOM-AVR Integrated Development Environment (IDE)
• AVRDUDE-GUI
• WinAVR-2010
• USBasp Driver

Block Diagram:

Algorithm:

1. R=rightmost sensor which reads 0, L=leftmost sensor which reads 0. If no sensor on right (or Left) is 0 than L (or R) equals to 0.
2. If all sensor read 1 then go to step 3,
3. Else,

If L

If L>R Move Left

If L=R Move Forward

4. Move anticlockwise if line was last seen on Left, Move clockwise if line was last seen on Right. Repeat step 3 till line is found.

Circuit Diagram:

Consider the eagle software based schematic circuit of line follower robot is:-

Source Code:

1. \$regfile = "m16def.dat".
2. \$crystal = 1000000
3. Config Lcd = 16 * 2
4. Config Lcdpin = Pin , Rs = Portb.2 , E = Portb.3 , Db4 = Portb.4 , Db5 = Portb.5 , Db6 = Portb.6 , Db7 = Portb.7
5. Config Adc = Single , Prescaler = Auto , Reference = Avcc
7. Config Timer1 = Pwm , Pwm = 8 , Prescale = 1 , Compare A Pwm = Clear Down , Compare B Pwm = Clear Down
8. Start Timer1
9. Dim Lb As Integer , Lw As Integer , Lm As Integer , L As Integer
10. Dim Rb As Integer , Rw As Integer , Rm As Integer , R As Integer
11. Cls
12. Lcd "sense black"
13. Wait 5
14. Lb = Getadc(1)
15. Rb = Getadc(0)
16. Lowerline
17. Lcd Lb ; "_" ; Rb
18. Wait 1
19. Cls
20. Lcd "sense white"
21. Wait 5
22. Lw = Getadc(1)
23. Rw = Getadc(0)
24. Lowerline
25. Lcd Lw ; "_" ; Rw
26. Wait 1
27. Cls
28. Lm = Lw + Lb
29. LmLm = Lm / 2
30. Rm = Rw + Rb
31. RmRm = Rm / 2
32. Do
33. Cls
34. L = Getadc(1)
35. R = Getadc(0)
36. If L < Lm And R < Rm Then
37. Lcd "fwd"
38. Pwm1a = 100
39. Portd.6 = 0
40. Pwm1b = 100
41. Portd.3 = 0
42. Elseif L > Lm And R < Rm Then
43. Lcd "left"
44. Pwm1a = 100
45. Portd.6 = 0
46. Pwm1b = 0
47. Portd.3 = 0
48. Elseif L < Lm And R > Rm Then
49. Lcd "right"
50. Pwm1a = 0
51. Portd.6 = 0
52. Pwm1b = 100
53. Portd.3 = 0
54. Elseif L > Lm And R > Rm Then
55. Lcd "stop"
56.  Pwm1a = 0
57.  Portd.6 = 0
58.  Pwm1b = 0
59.  Portd.3 = 0
60. End If
61.   Loop
62.
63. End

Consider the screenshot of source code used in Line Follower robot using BASCOM-AVR Integrated Development Environment (IDE) is:-