Extra ideas
You can make a test track that crosses; this needs to work a little like train crossings—in that there are white lines cutting through the black lines for the two sensors either side to pass through.
Adding an LED facing down in the robot to control the light under may make the sensors more stable, although they do have their own IR LEDs too.
Using magnetic hall effect sensors and a wire, there are ways to make a hidden track under a floor or an MDF board, for example. The wire needs some electricity passing through. The full details are outside the scope of this book, but this is a fun idea.
You could also paint an inverted track, with a black background and a white line then modify the code to deal with that. Pi Wars supplies ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access