Operation Manual

A beginner’s guide to Scratch
38
Line-following vehicle (LFV)
RESOURCES: The sprite “yellow_car” and the background “line_background”.
That robot is like something out of a corny science-fiction film. Let’s look at a
more modern example. Scientists are experimenting with vehicles that can drive
themselves. One way of doing this is by programming the vehicle to follow a line
painted on the road surface. These vehicles are known as “line-following vehicles”,
or LFVs.
In this exercise, we’ll look in more detail at the blocks in the Sensing section.
Our task is to make a car to follow a line, just like the real engineers designing
LFVs for use on the roads. Our main tool is going to be the “color [ ] is touching [ ]?”
block from the Sensing menu.
This block allows a program to detect when an area of one colour touches against
another colour: for instance, as in the screenshot above, a patch of red touches a
patch of black.
Notes:
The Sensing
script blocks
allow your
program to sense
changes in its
environment,
either in
response to user
input or events in
the program.