There's not much originality in this, it's a very common project but I've done my take on it and added it here. What is different are the mods to the original Robot Car kit made using 3D printed parts. It was also my first attempt, but didn't go well so the Line Follower 1 version was bought to see where I was going right or wrong.
To fit on the supplied chassis I designed a set of slotted frames to which the detectors could be attached. The one shown in the picture has nine slots across the front to accommodate different detector circuits easily bolted on and adjusted. There are four designs to use in different positions, as well as a microswitch bracket and a camera mount.
Having assembled the parts, the experimenting began and the first thing I learnt was it didn't work. In typical fashion I looked at others work, videos of constructed line followers and took a simple approach to a short piece of code to follow a line detected by the sensors. Detecting the line, ok, driving the motors, fine, but combining the two was a lot more difficult.
The main problem was overrun, the detectors 'saw' the line, the power to the motors was cut, but chassis moved on a couple of cm and either went past the line completely or occasionally triggered the opposite sensor. Both events causing the robot to wander off the course.
Several solutions were attempted. Cutting the power to the motors using PWM could only slow the chassis a small amount before the motors stalled and not enough to improve the accuracy. A reverse routine was added to move the robot back 2cm on each detection was partly successful, but painful to watch the shuffling back and forth, and ultimately the sensors would miss and off it would go again in a random direction.
Lesson 1 learnt on this is that the mechanics of even just a 'simple' line follower are vital to it's success. It takes a lot of effort to correct inbuilt inaccuracies. Lesson 2 learnt is that placing the controller centrally makes wiring a lot easier!
So I bought a kit (Line Follower 1), and that worked successfully, if awkwardly. I wanted to be able to improve on it easily and decided to replicate it's operation on this chassis before moving on. This meant making some new sensors which oddly weren't available off the shelf.
Both the sensors I'd been using, and the OTS line follower used the LM393 comparator IC to convert an analogue signal into a digital switch which provided input to the following action. As a starting point to a sensor, I decided to use an analogue signal to see just what range of values I would expect to see.