1 of 1 people found this helpful
this link shows a good example including theory, schematics and code: https://circuitdigest.com/microcontroller-projects/line-follower-robot-using-arduino
As a matter of fact there are more than one way to reach the goal. The shown example is one of the most used where the light sensor individuate the line based on the light contrast with the background.
Just a thing to take in account: when you reach the prototype and test the code, maybe you see that the line is followed with a too irregular path (i.e. zig-zag ) This is due to the precision of the robot and mostly depends on the frequency the line is checked. You should find a good average to not overcharge the processor and avoid too compulsive movement.