We started with a new approach to line following. Initially we attempted to use 5 IR sensors but we found there was too much overlap in the reflection of the IR beams, causing inaccurate readings. We switched to 3 sensors, but still had problems. Firstly we added fairings to block the overlap. Then we switched to following a white line on a black background (luckily the kitchen table was black!). These changes resulted in setup the could reliably detect the line. Now we needed so code....
We started by creating our own algorithm which gave each of the line sensors a number which is what we used to to set the motor steering angle to. However we found that we kept overshooting the sharp turns, so we added a small code snippet to make it reverse when we overshot the end of the line. This worked but was not very reliable.
We had read previously (See book review on "Robotics at Home with Raspberry Pi Pico") about using a PID algorithm. However it sounded complicated to code, so was asked Bing Co-Pilot "write the code in CircuitPython to do line following using PID algorithm with 3 digital line sensors, driving 2 motors". We modified this to use out own motor setup functions and watched it wiggle down the line. After a bit of tuning, success! We had a pretty reliable line following robot.