but i want to add an operation that is the robot If got away from the line how can it search and get back to the line again automatically ?
Leaving aside the question of how you might write a program finding a line not a simple thing. You could make the robot move in some direction hoping that it will run across a line. But what direction would you choose and when would you decide that the direction was never going to cross a line? And if you did decide that you were searching in the wrong place, how would you decide where to search next? There is also the problem of making the robot move in a straight line if it does not have a line to follow.
This is the sort of thing that is easy for a human with a sophisticated vision system, but could be incredibly difficult for a robot with a few line-detector sensors.
I have not looked at your program. To make it easier for people to help you please modify your post and use the code button </>
so your code looks like this
and is easy to copy to a text editor. See How to use the Forum
Your code is too long for me to study quickly without copying to a text editor.