Line tracking
The Linefinder sensors send out an infrared signal which is reflected when it hits a light background and thus returns a high signal (1). If the infrared signal hits a dark background, such as a painted black line, the signal is not reflected and the sensor returns a low signal (0).
This allows the JoyCar with its three linefinder sensors on the bottom side to follow a painted black line on its own. We have prepared a small demo program for this purpose.
With button A on your micro:bit you can switch the line tracking mode on and off.
For a better overview of which action has to be performed at which sensor values, we have created a truth table here.
Linefinder Left | Linefinder Middle | Linefinder Right | Action |
0 | 0 | 0 | straight |
0 | 0 | 1 | slightly left |
0 | 1 | 0 | stop |
0 | 1 | 1 | left |
1 | 0 | 0 | slightly right |
1 | 0 | 1 | straight |
1 | 1 | 0 | right |
1 | 1 | 1 | circling |