Two sonar sensors were used in the final design. The "forward" facing sonar sensor allowed the robot to determine which direction of the tape it was on once each round started. With this information, the robot knew whether to drive forward or backward. The second sensor pointed to the "left" of the robot. Once the robot had collected balls, this sensor would be used if the robot was no longer on the line. If it wasn't on the line, the sensor would tell the robot which way to turn to find the line again.
Note that sensor 1 required two pins, TRIG and ECHO. The sonar sensor could be used without any special libraries simply by sending a pulse (using TRIG), and checking ECHO to see when a pulse was returned. The time it took for the pulse return determined the distance sensed. A library was written (NewPing) that allowed the sensors to require only one output pin for both TRIG and ECHO. At the end of the project, with few pins left over for the second sensor, this library was used to reduce the number of pins required.