There is a 16mm wide black reack on the white ground. Our track car can run automatically along the black track.
No matter how curved the track is, the car can be driven automatically.
We all know that when the light source hits a white obect and a black object, the light reflectance is different.
Here we use the red LED as a light source. The light is reflected by the ground to the photoresistor.
It can be judged whether the car is driving or not by detecting the resistance change of the photoresistor.
In the white area, if a black track is detected, it indicates that the car is deviated and the motor on this side decelerates or enen stops.
The green LED on the side is extinguished, driving the car in the opposite direction, so that the car can always follow the track was running.