The final project in Electronics for MEs was to build and program a line following robot. The basic chassis was supplied (power supply, sensors, motors, breadboard), and our job was to control it all with an Arduino Nano and some Pololu motor drivers. We also added LEDs for debugging purposes. This video of another team's robot shows the course (we have no footage of our robot). My partner, Luke Plummer, and I ended up winning the competition and setting a class record with a time of 39 seconds.
Our code (not posted in full to prevent current students from using it) utilized the three supplied light sensors. At the beginning of every run, our robot performed a brief calibration. Light levels made it difficult to use the full range of our sensors, so we created a sequence that measured "full white" and "full black" light levels on the course. From there, a proportional controller and a state machine kept the robot on the course at full speed. Instead of tracking the middle of the line, it stayed to one side to allow corners to be quickly detected.