The code is in NXC and I used the NXT Camera. To follow the line, the robot uses a simple PID. The robot uses the sonar to find objects by the road. It uses the light sensor to detect whether it found the right object.

Source code: